cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <>
Subject Re: Missing DbAttribute
Date Thu, 27 Jul 2006 18:11:12 GMT
On 7/27/06, cay dabbler <> wrote:
> Thanks for your quick reply. I am frustrated with a whole host of
> velocity2ejb generators.  I find Cayenne more useful for my purpose even
> though it does not make grand claims - as the other generators do.

It's all velocity underneath -- it's just a matter of how you put
things into the context.

> I am using Cayenne to generate EJB 3.0, JSF and Webservice – true, and a
> whole load of other stuff. I am particularly attracted to Cayenne
> inheritance facilities.

Cool.  I'm also using Cayenne to generate JSF-related information
(converters, selectItemProviders, some DAO objects and matching
faces-config files, and facelet pages for each DataObject.

I'm using vertical inheritance which isn't directly supported by
Cayenne, but which can be simulated using custom templating and a
delegation pattern.

> I do want to map DbAttributes to the corresponding ObjAttributes, but I
> don't know what I am doing wrong.
> Scenario:
> 1 In my database schema
> 2. In Cayenne
> a) I make Foo1 the superclass of Foo2
> b). FOO1_TABLE has a row defined:  NAME=toFoo2Table , TARGET=FOO2_TABLE, To
> Dep PK= true;
> Problem:
> I don't know why (2b) is necessary. Anyway, I deleted the row and that's
> when my problem started. If I don't remove it, I get something like:
> Class Foo1{
> private  Foo2  toFoo2; // UGLY, DON'T WANT THIS
> }
> Class Foo2 extends Foo1{
> }

If I understand correctly, this db attribute relationship simply says
that the primary key for Foo1 will always be the same as Foo2 (the
foo1 primary key is dependent on foo2).   This is probably true in
your case.

Can't really help on the inheritance part.   With vertical
inheritance, foo2 doesn't actually extend foo1.   Instead, delegating
methods are made in foo2 for each foo1 attribute.

Ie,    Foo2.getFoo1Attribute is generated as
getFoo1().getFoo1Attribute() underneath.

> One more thing:
> In the Cayenne API doc, The ObjAttribute class has:
> DbAttribute getDbAttribute();
> It would be nice to have in the DBAttribute: class
> ObjAttribute  getObjAttribute();

It's not that straight-forward.   Every ObjAttribute has a
DbAttribute, but every DBAttribute can have zero or one or probably
even many matching ObjAttributes.

View raw message