I'm trying to call Session.replicate() with persistent objects mapped with joined-subclass and I'm getting a JDBCException.
Code:
net.sf.hibernate.JDBCException: could not retrieve version: [com.foo.bar.data.synch.Synch#com.foo.bar.data.sites.CompositeSiteID@1d97d0d[sequenceId=965,site=com.bpsphone.mpression.data.sites.Site@39d811[id=3]]]
at net.sf.hibernate.persister.AbstractEntityPersister.getCurrentVersion(AbstractEntityPersister.java:1141)
at net.sf.hibernate.impl.SessionImpl.replicate(SessionImpl.java:3698)
at....
Here's the offending SQL:
Code:
select version from synch.synch where sequence_id =? and site =?
Here's the mapping:
Code:
<hibernate-mapping default-cascade="all">
<class name="com.foo.bar.data.base.SiteDataObject" schema="base" table="site_data_objects">
<composite-id name="id" class="com.foo.bar.data.sites.CompositeSiteID" unsaved-value="any">
<key-property name="sequenceId" type="java.lang.Long" column="sequence_id"/>
<key-many-to-one name="site" class="com.foo.bar.data.sites.Site" column="site"/>
</composite-id>
<version name="version" type="timestamp" unsaved-value="null"/>
<joined-subclass name="com.foo.bar.data.synch.Synch" schema="synch" table="synch">
<key><column name="sequence_id"/><column name="site"/></key>
</joined-subclass> <!-- Synch -->
</class> <!-- SiteDataObject -->
</hibernate-mapping>
The problem is that the column "version" does not exist in the synch table, it exists in the table of Synch's parent object, SiteDataObject. Hibernate isn't joining in the version column from the base.site_data_objects table like it normally would.
In the case of joined-subclasses, can the "version" attribute be in the superclass, or must it be defined in the subclasses? If so, what about multiple level object heirarchies? Also, I've had problems with every persistent object mapped with joined-subclass, not just Synch.
I'm replicating another object that's mapped with a regular <class> mapping. No problems there. I have no classes mapped with <subclass> though, so I haven't tested that.
Thanks!