cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Meyer - KMZ" <ke...@kmz.co.za>
Subject Re: Is it possible/easy to integrate cayenne with other frameworks?
Date Mon, 12 Dec 2011 06:49:52 GMT
On 11 Dec 2011 at 20:28, Andrus Adamchik wrote:

> 
> On Dec 11, 2011, at 7:00 PM, Kevin Meyer - KMZ wrote:
> 
> > I wish it were this simple. But the problem lies in
> > 	DataContext#newObject(String entityName)
> > once it has created an instance of my POJO, it type casts it to 
> > Persistent:
> >            object = (Persistent) descriptor.createObject();
> > 
> > This *forces* my POJO to implement Persistent.
> 
> You may have to do the wrapping on your own after that I guess... If it is at all possible.
> 
> IIRC elsewhere in this thread you said you were OK with Isis objects
> extending CayenneDataObject. CayenneDataObject implements Persistent
> of course. So maybe there was some misunderstanding earlier in this
> discussion? If your object really has to be a POJO (as in Java class
> with no special superclass and data contained in the user-defined
> fields), we need to backtrack quite a bit and reevaluate the
> problem. 

I'm learning as I go along.

Initially, I did not realise there would be a problem with the Isis 
introspector and CayenneDataObject.

Fortunately, Isis provides a mechanism to bypass introspecting certain 
classes, so I am making my POJO extend CayenneDataObject and 
am on to the next stage.

So - to recap: I have my POJO that Isis can introspect. I have 
examined the fields and created:
DbEntity, ObjEntity for each POJO.
For each property, I have created:
DbAttribute, ObjAttribute
and set the appropriate setEntity() to the entities created above.



I can create an instance of my POJO with newInstance().

I'm now getting a null pointer assignment when I try and commit!

So far, I have tracked into:
                createPermIds(descriptor, objects);
in DataDomainInsertBucket#appendQueriesInternal

> 
> > Why doesn't Cayenne support composition over inheritance? I think 
> > the idea of containing the CayenneDataObject as suggested provides 
> > much greater flexibility... and you generate these classes, anyway.
> 
> In the Isis integration case - maybe. I don't think we've ever
> considered using a delegate to give persistent objects a semblance
> of a POJO by removing a requirement for a superclass, but still
> forcing our own internal structure. So it is probably worth a
> discussion, although I am cautiously pessimistic about it being done
> easily at Cayenne level. 

Indeed - I started putting together something in the DataContext that'll 
fetch the container via a getPersistent or equivalent, and realised that 
some additional wrappers will be needed to access the POJO again.

I'll put that on the back-burner for a while.

Regards,
Kevin


Mime
View raw message