persistence@glassfish.java.net

Re: TOPLINK-45 error - how to join two entities via an alternate key (vs. a primary key)

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Thu, 19 Feb 2009 10:51:01 -0400

That is the most common setup for a foreign key relationship. Can you
send the Entities?
--Gordon

pdecker wrote:
> Gordon,
>
> Thanks for the reply. I just checked with the DBA and the field I am trying
> to use in the join is just a field with a UNIQUE constraint on it; so it's
> not a key, and its not part of the primary key. I am guessing that I cannot
> use Toplink to join on such a field. Am I correct on this?
>
> Again, thanks for your help.
>
>
>
> Gordon Yorke-2 wrote:
>
>> Not sure what you mean by "alternate key". Does the LuAppList now have
>> a compound PK? If this "alternate key" is not part of the PK but the
>> mapping was the PK before make sure you have *not* marked the @Id
>> mapping in LuAppList with updatable=false, insertable=false.
>> --Gordon
>>
>> pdecker wrote:
>>
>>> Hello,
>>>
>>> I am using Toplink and have 2 entity beans: Logger and LuAppList. There
>>> is a
>>> many-to-one relationship from Logger to LuAppList. The Logger table has a
>>> foreign key reference to an alternate key in LuAppList (not the primary
>>> key). When running the app, I get this error from the glassfish system
>>> log:
>>>
>>> TOPLINK-45 Missing mapping for field [LU_APP_LIST.app_id]
>>>
>>> It works when its mapped to a primary key. But the database table design
>>> has
>>> changed and the foreign key is now an alternate key.
>>>
>>> Does anyone know if this should work, or how to fix it?
>>>
>>> Thanks for your attention.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
>