hi atipon,

ok, then i'll check it in.

thanks
jakob
----- Original Message -----
From: "atipon pongpat" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Thursday, October 24, 2002 7:15 PM
Subject: Need PersistentField impl suggestion


>
> Hi Jakob
>   Odmg parser work fines for me :-). It runs smoothly on my few testcase.
> Thanks,
> Atipon
>  Jakob Braeuchi <[EMAIL PROTECTED]> wrote:hi atipon,
>
> i have modified oql-grammar to accept -> notation.
> i'll check it in as soon as you give your ok.
>
> please get the latest Criteria from repository.
> the zip contains all files from org.apache.ojb.odmg.oql.
>
> hth
> jakob
>
> ----- Original Message -----
> From: "atipon pongpat"
> To: "OJB Users List"
> Sent: Monday, October 21, 2002 7:26 PM
> Subject: Need PersistentField impl suggestion
>
>
> >
> > Hi thomas, Jakob
> > Jakob's right. A dot notation does not work with ojb query. I
> prefer "->" like Thomas.
> >
> > If you want to use this impl with ojb query criteria, I think it
> should override getName method like this.
> >
> > public String getName() {
> >
> > return this.fieldName;
> >
> > }
> >
> > For odmg parser, I guess it doesn't accept a symbol like "#" or "->",
> correct me if I'm wrong.
> >
> > Regards,
> >
> > Atipon
> >
> >
> >
> > Thomas Mahler wrote:
> > Hi again Jakob,
> >
> > Jakob Braeuchi wrote:
> > > hi atipon, thomas,
> > >
> > > does this solution interfere with path expressions and joins ?
> >
> > Oops, I missed this.
> >
> > > given you have an attribute named 'audit.createdBy' in a selection
> criteria.
> > > when building the sql, ojb will try to find a relationship called
> 'audit'
> > > because of the dot-notation.
> >
> > You are right.
> >
> > > this problem coud eventually be solved by using another notation
> > > (audit#createdBy, audit->createdBy).
> > >
> >
> > I'd prefer "->" as most people will recognize it as signaling a
reference.
> >
> > Any comments?
> >
> > cheers,
> > Thomas
> >
> >
> > > just my CHF 0.02
> > >
> > > jakob
> > >
> > > ----- Original Message -----
> > > From: "Thomas Mahler"
> > > To: "OJB Users List"
> > > Sent: Sunday, October 20, 2002 12:12 PM
> > > Subject: Re: Need PersistentField impl suggestion
> > >
> > >
> > >
> > >>Hi Atipon,
> > >>
> > >>atipon pongpat wrote:
> > >> > Hi, My company currently uses Toplink for o/r mapping, so I want to
> > >> > write an ojb mapping without any modification to existing domain
> > >> > object. The problem arises when I try to map nested object on the
> > >> > same table of parent object. My first solution is rowreader + field
> > >> > conversion.(Thanks to Thomas Mahler for his response to my friend,
> > >> > Sumeth Chittaprawat) It works fine but I just don't want to write a
> > >> > rowreader for every class that has a nested object. I decided to
> > >> > extend ojb provided PersistentField impl to supports using of
nested
> > >> > attribute. My repository looks something like this.
> > >>
> > >>Hey, this is a cool idea! I've never thought of this solution.
> > >>I think we should integrate it into the main distribution. As it will
> > >>solve a lot of problems.
> > >>
> > >> > >> > id="2" name="name" column="SUPP_NAME" jdbc-type="CHAR" />
> > >> >
> > >> > >> > jdbc-type="CHAR" />
> > >>
> > >> > Is there something I have to concern when I
> > >> > create my own PersistentField impl ?
> > >>
> > >>No, no problems to be expected.
> > >>
> > >> > I'm afraid that it cannot be
> > >> > used with odmg or jdo api.
> > >>
> > >>I don't see any problems.
> > >>
> > >>cheers,
> > >>Thomas
> > >>
> > >> >
> > >> > Thanks in advance, Atipon Pongpat
> > >> >
> > >> > P.S. This my code. Any comments or suggestions are welcome. package
> > >> > testojb;
> > >> >
> > >> > import java.lang.reflect.Field;
> > >> >
> > >> > import org.apache.ojb.broker.metadata.MetadataException; import
> > >> > org.apache.ojb.broker.metadata.PersistentFieldMaxPerformanceImpl;
> > >> > import org.apache.ojb.broker.util.logging.Logger; import
> > >> > org.apache.ojb.broker.util.logging.LoggerFactory;
> > >> >
> > >> > /** * * This class supports using of nested attribute. * @author
> > >> > Atipon Pongpat */ public class
> > >> > PersistentNestedFieldMaxPerformanceImpl extends
> > >> > PersistentFieldMaxPerformanceImpl {
> > >> >
> > >> > private String fieldName;
> > >> >
> > >> > private Logger logger = LoggerFactory.getLogger(this.getClass());
> > >> >
> > >> > public PersistentNestedFieldMaxPerformanceImpl(Field f) {
super(f); }
> > >> >
> > >> >
> > >> > public PersistentNestedFieldMaxPerformanceImpl(Class c, String
> > >> > fieldname) { super(c, fieldname); this.fieldName = fieldname; }
> > >> >
> > >> > /** * @see
> > >> >
> org.apache.ojb.broker.metadata.PersistentFieldMaxPerformanceImpl#getF-
> > >> > ieldRecursive(Class, String) */ protected Field
> > >> > getFieldRecursive(Class c, String fieldname) throws
> > >> > NoSuchFieldException { //thanks for the original implementation of
> > >> > PersistentFieldMaxPerformanceImpl try { Field f = null; int index =
> > >> > fieldname.indexOf("."); if (index >= 0) { String name =
> > >> > fieldname.substring(0, index); Field field =
> > >> > c.getDeclaredField(name); Class nestedClass = field.getType(); //
> > >> > String nestedName = fieldname.substring(index + 1); f =
> > >> > getFieldRecursive(nestedClass, nestedName); } else { f =
> > >> > c.getDeclaredField(fieldname); } return f; } catch
> > >> > (NoSuchFieldException e) { // if field could not be found in the
> > >> > inheritance hierarchy, signal error if (c == Object.class) { throw
e;
> > >> > } // if field could not be found in class c try in superclass else
{
> > >> > return getFieldRecursive(c.getSuperclass(), fieldname); } } }
> > >> >
> > >> > /** * @see
org.apache.ojb.broker.metadata.PersistentField#get(Object)
> > >> > */ public Object get(Object anObject) throws MetadataException {
> > >> > return getNestedObject(anObject, fieldName); }
> > >> >
> > >> > /** * @see
org.apache.ojb.broker.metadata.PersistentField#set(Object,
> > >> > Object) */ public void set(Object obj, Object value) throws
> > >> > MetadataException { setNestedObject(obj, fieldName, value); }
> > >> >
> > >> >
> > >> > /** * Set nested attribute with given value. * @param obj the
object
> > >> > whose field should be modified * @param fieldName nested attribute
> > >> > name * @param value the new value for the field of obj being
modified
> > >> > */ protected void setNestedObject(Object obj, String fieldName,
> > >> > Object value) {
> > >> >
> > >> > int index = fieldName.indexOf("."); if (index >= 0) { String name =
> > >> > fieldName.substring(0, index); PersistentFieldMaxPerformanceImpl
> > >> > pField = new PersistentFieldMaxPerformanceImpl(obj.getClass(),
name);
> > >> > Object attrib = pField.get(obj);
> > >> >
> > >> > if (attrib == null) { try { attrib =
pField.getType().newInstance();
> > >> > } catch (InstantiationException e) { throw new MetadataException(
> > >> > "Error instantiate field:" + name + " in object:" +
> > >> > obj.getClass().getName(), e); } catch (IllegalAccessException e) {
> > >> > throw new MetadataException( "Error getting field:" + name + " in
> > >> > object:" + obj.getClass().getName(), e); }
> > >> >
> > >> > pField.set(obj, attrib); } // String nestedName =
> > >> > fieldName.substring(index + 1);
> > >> >
> > >> > setNestedObject(attrib, nestedName, value); } else {
> > >> >
> > >> > PersistentFieldMaxPerformanceImpl pField = new
> > >> > PersistentFieldMaxPerformanceImpl( obj.getClass(), fieldName);
> > >> > pField.set(obj, value); }
> > >> >
> > >> > }
> > >> >
> > >> > /** * Get nested attribute with given field name. * @param obj
object
> > >> > from which the represented field's value is to be extracted *
@param
> > >> > fieldName nested attribute name * @return Object the value of the
> > >> > represented field in object obj */ protected Object
> > >> > getNestedObject(Object obj, String fieldName) {
> > >> >
> > >> > Object result = null; int index = fieldName.indexOf("."); if (index
> > >> > >= 0) { String name = fieldName.substring(0, index);
> > >> > PersistentFieldMaxPerformanceImpl pField = new
> > >> > PersistentFieldMaxPerformanceImpl(obj.getClass(), name); Object
> > >> > attrib = pField.get(obj);
> > >> >
> > >> > if (attrib != null) { // String nestedName =
> > >> > fieldName.substring(index + 1); result = getNestedObject(attrib,
> > >> > nestedName); } } else {
> > >> >
> > >> > PersistentFieldMaxPerformanceImpl pField = new
> > >> > PersistentFieldMaxPerformanceImpl( obj.getClass(), fieldName);
result
> > >> > = pField.get(obj); }
> > >> >
> > >> > return result; }
> > >> >
> > >> > }
> > >> >
> > >> >
> > >> >
> > >> >
> > >> > --------------------------------- Do you Yahoo!? Y! Web Hosting -
Let
> > >> > the expert host your web site
> > >>
> > >>
> > >>
> > >>
> > >>--
> > >>To unsubscribe, e-mail:
> > >>For additional commands, e-mail:
> > >>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > For additional commands, e-mail:
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
> >
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Y! Web Hosting - Let the expert host your web site
> > ATTACHMENT part 2 application/x-zip-compressed name=oql.zip --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
>
>
> ---------------------------------
> Do you Yahoo!?
> Y! Web Hosting - Let the expert host your web site


--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to