cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <mkien...@gmail.com>
Subject Re: Getting property type information for JBND
Date Mon, 19 May 2008 21:09:21 GMT
If you already have a non-fault DataObject, you can do all of this by
following the relationship: DataObject -> ObjEntity -> ObjRelationship
-> other ObjEntity -> ObjAttributes.  But I don't think this is what
you're asking for.

If you're starting with a Fault where all you have is the class name,
use dataContext.getEntityResolver().lookupObjEntity(dataObject);
then -> ObjRelationship -> other ObjEntity -> ObjAttributes

On 5/19/08, Dirk Lattermann <dlatt@alqualonde.de> wrote:
> The following may boil down to "How can I get entity/property
>  information on a Fault object?", but I'm not sure. Let me explain:
>
>  To use Cayenne in a Swing application, I found JBND yesterday after
>  browsing this list. It didn't seem too complicated to implement the
>  needed org.jbnd.DataObject interface for the CayenneDataObjects, so I
>  gave it a naïve try.
>
>  I used a custom superclass for the objects generated by the Cayenne
>  modeler. Most things were rather straightforward and work to a small
>  amount. Then I stumbled over a problem which seems to be connected to
>  Faults.
>
>  A JBND DataObject must be able to return a JBND DataType which
>  describes, among others, its properties. To determine the type of a
>  property (attribute, to-one or to-many), I use
>
>  -----------
>   objEntity = JBNDCayenneObject.this.getObjEntity();
>   if (objEntity.getAttribute(key) != null) return DataType.ATTRIBUTE_KEY;
>   if (objEntity.getRelationship(key) != null)
>   {
>     if (objEntity.getRelationship(key).isToMany()) return
>  DataType.TO_MANY_KEY;
>     else return TO_ONE_KEY;
>   }
>  -----------
>
>  now, in a to-many-relationship, the JBND framework asks for the type of
>  a property of a descendant object. A
>    System.out.println(JBNDCayenneObject.this)
>  reveals
>    {<no id>; transient; []}
>
>  This indicates a yet unfetched object (Fault), right?
>  Apparently, even though JBNDCayenneObject.this.getClass() is the
>  correct class of my data object, the getObjEntity() returns null.
>
>  How can I obtain the property information in this case?
>  Maybe it should be done via the DataMap and object entity name, but how
>  do I find and access the DataMap?
>  Even JBNDCayenneObject.this.getObjectId() returns null!
>
>  Thank you!
>
> Dirk
>
>
Mime
View raw message