cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Meyer - KMZ" <>
Subject Re: Is it possible/easy to integrate cayenne with other frameworks?
Date Mon, 12 Dec 2011 05:00:13 GMT
By the way, I'm using Cayenne 3.1M4-SNAPSHOT.

> I don't really know what you're doing, but what about something like this:
> class POJO {
>     CayenneDataObject delegate;
>     public POJO() {
>     }
>     public setDelegate(CayenneDataObject cdo) {
>          this.delegate = cdo;
>     }

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 
            object = (Persistent) descriptor.createObject();

This *forces* my POJO to implement Persistent.

Is there another way to create an instance of my POJO ?

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.

View raw message