cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <>
Subject Re: BUG: Cayenne Modeler
Date Mon, 01 Feb 2010 17:44:53 GMT
Again, I'm not using Cayenne in any current project, so it's hard for
me to comment on anything other than concepts right now.

You would want an E1.COMPLEX_TYPE_ID foreign key in your table and in
your DbEntity.

More than likely, you do not want your ObjEntity E1 to have a
"complexTypeId" attribute.   Instead, you want to only have a to-one
"complexType" relationship.   This is what the Modeler is offering to
automatically remove for you.   Apparently, the remove operation has a
bug :)   You can always remove "complexTypeId" manually yourself.

And it probably will not hurt anything if you leave the attribute
there other than leave some unnecessary attributes in the model.

On Mon, Feb 1, 2010 at 12:21 PM, Joe Baldwin <> wrote:
> Mike,
> Thanks, we all probably need to understand this for better Cayenne Modeler designing.
 I am still confused by some of your comments ...
>> This is a foreign key mapped as an object attribute as opposed to a relationship
"toArtist" from painting to artist.
> I am not sure what the distinction is that you are intending.  I originally added the
foreign key as an attribute and (assuming that I am taking the correct steps) am mapping the
relationship using Cayenne Modeler.  I have never seen the CayenneModeler warning prior to
> The only difference in my procedure in this case is the order in which I mapped the relationship.
 I have an entity (E1) that requires a classification (aka complex type), and I  implemented
that "complex type" definition as another database table (E2).  Therefore from the perspective
of E1 there is a "to-one" relationship (i.e. so you can then say: E1 is a type of E2).  For
this design, it is not terribly useful to think of the "type" E2 as having a collection of
E1's.  *However*, when I define the "to-one" relationship as I describe above, Cayenne modeler
auto-magically creates a "to-many" reverse relationship.
> Under normal circumstances I typically define the "to-many" relationship first, but not
this time.  I was wondering if this could have precipitated the error with CM?
> BTW, I did the same steps last night with another Entity and got the same freeze, then
crash.  It appears that this condition might be creating an infinite loop (because it takes
about 3-4 minutes before the modeler crashes and all functions are frozen during this time).
 My work-around to avoiding a crash was to decline CM's offer to "remove the foreign key".
> It would be nice to understand a bit more about what CM is assuming so that I can feel
more confident about my work-around.
> Joe
> On Feb 1, 2010, at 11:29 AM, Mike Kienenberger wrote:
>> I won't address the crash, but I can explain what it should mean.
>> Assume you have a column ARTIST_ID in table PAINTING, which is a
>> foreign key to table ARTIST.
>> When the ObjEntity was set up, assume an "artistId" attribute was created.
>> This is a foreign key mapped as an object attribute as opposed to a
>> relationship "toArtist" from painting to artist.
>> Normally you don't need direct access to the foreign key, so the
>> modeler is asking you if you want to get rid of "artistId" and other
>> such attributes.
>> On Sun, Jan 31, 2010 at 6:11 PM, Joe Baldwin <> wrote:
>>> Tried to save a project with a new Entity (which had a many to one relationship).
 When I selected "Save" the following panel was displayed:
>>>        Remove Foreign Keys mapped as object attributes?
>>> Not sure what this would accomplish, I selected "Yes", which appears to be the
wrong answer because Cayenne Modeler crashed big time. (see auto report below)
>>> Joe
>>> CayenneModeler Info
>>> Version: cayenne.version
>>> Build Date:
>>> Exception:
>>> =================================
>>> java.lang.OutOfMemoryError: Java heap space
>>>        at java.util.Collections$UnmodifiableCollection.iterator(
>>>        at
>>>        at org.apache.cayenne.modeler.undo.DbEntitySyncUndoableEdit$MeaningfulFKsUndoableEdit.<init>(
>>>        at org.apache.cayenne.modeler.action.DbEntitySyncAction.synchDbEntity(
>>>        at org.apache.cayenne.modeler.action.DbEntitySyncAction.performAction(
>>>        at org.apache.cayenne.modeler.util.CayenneAction.actionPerformed(
>>>        at javax.swing.AbstractButton.fireActionPerformed(
>>>        at javax.swing.AbstractButton$Handler.actionPerformed(
>>>        at javax.swing.DefaultButtonModel.fireActionPerformed(
>>>        at javax.swing.DefaultButtonModel.setPressed(
>>>        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
>>>        at java.awt.AWTEventMulticaster.mouseReleased(
>>>        at java.awt.Component.processMouseEvent(
>>>        at javax.swing.JComponent.processMouseEvent(
>>>        at java.awt.Component.processEvent(
>>>        at java.awt.Container.processEvent(
>>>        at java.awt.Component.dispatchEventImpl(
>>>        at java.awt.Container.dispatchEventImpl(
>>>        at java.awt.Component.dispatchEvent(
>>>        at java.awt.LightweightDispatcher.retargetMouseEvent(
>>>        at java.awt.LightweightDispatcher.processMouseEvent(
>>>        at java.awt.LightweightDispatcher.dispatchEvent(
>>>        at java.awt.Container.dispatchEventImpl(
>>>        at java.awt.Window.dispatchEventImpl(
>>>        at java.awt.Component.dispatchEvent(
>>>        at java.awt.EventQueue.dispatchEvent(
>>>        at java.awt.EventDispatchThread.pumpOneEventForFilters(
>>>        at java.awt.EventDispatchThread.pumpEventsForFilter(
>>>        at java.awt.EventDispatchThread.pumpEventsForHierarchy(
>>>        at java.awt.EventDispatchThread.pumpEvents(
>>>        at java.awt.EventDispatchThread.pumpEvents(
>>>        at

View raw message