users@glassfish.java.net

Lazy OneToOne with composite key failing

From: Shevland, Joe <joe.shevland_at_capgemini.com>
Date: Fri, 6 Jul 2007 11:40:55 +1000

I've been trying to setup a unidirectional @OneToOne relationship
between two entities, say EntityA and EntityB. Both use the same
@MappedSuperclass which has a composite primary key class using
@EmbeddedId.

I started with just this in EntityA:

   @OneToOne(fetch=FetchType.LAZY)
   public EntityB getEntityB() {...}

And that failed on having more than one writable mapping for a field.
Then I tried:

   @OneToOne(fetch=FetchType.LAZY)
   @PrimaryKeyJoinColumns({
      @PrimaryKeyJoinColumn(name="col1", referencedColumnName="DBCOL1"),
      @PrimaryKeyJoinColumn(name="col2", referencedColumnName="DBCOL2")
   })

And a similar @JoinColumns with insertable=false, and updatable=false
variant. During deployment, it falls over with:

Exception [TOPLINK-0] (Oracle TopLink Essentials - 2.0 (Build b50-beta3
(06/06/2007))): oracle.toplink.essentials.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------

Exception [TOPLINK-60] (Oracle TopLink Essentials - 2.0 (Build b50-beta3
(06/06/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: The method [_toplink_setentityB_vh] or
[_toplink_getentityB_vh] is not defined in the object [com.foo.EntityA].
Internal Exception: java.lang.NoSuchMethodException:
com.foo.EntityA._toplink_getEntityB_vh()
Mapping: oracle.toplink.essentials.mappings.OneToOneMapping[entityB]
Descriptor: RelationalDescriptor(com.foo.EntityA -->
[DatabaseTable(T_TABLE)])

I've found a few bugs in TopLink wrt OneToOne and composite keys while
googling (all of which indicate they were fixed a few months ago), and
this:

http://forums.java.net/jive/thread.jspa?threadID=19638&tstart=0

Which is quite old and I assume fixed (and the workaround in the last
comment doesn't work either). Any ideas on the best way to define a lazy
one-to-one relationship with a composite PK involved? Using build50 of
GF-v2.

Cheers
Joe

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.