knoll wrote:
hi,
can you post real code and the corresponding mapping files?
rgds
Hi,
Thanks for looking into this issue.
I'm using same session (always current session).
It works for all other update graphs(collections), this use case is slightly different. We have same User.Id as PrimaryKey (Address.userId is PK & FK, WebAddress – userId is PK&FK), basically same ID identifies all (because it’s 1-1 relation).
Mapping files:
code:
--------------------------------------------------------------------------------
*************
User*************
<hibernate-mapping> <class name="User" table="USER" lazy="false">
...............................................
<one-to-one name="address" class="Address" cascade="save-update,lock" lazy="no-proxy" access="field"/>
</class>
</hibernate-mapping>
--------------------------------------------------------------------------------
*************
Address.xml:
--------------------------------------------------------------------------------
<class name=" Address" table=" Address" lazy="false" discriminator-value=" Address">
<id column="USERID" type="string">
<generator class="foreign">
<param name="address">address</param>
</generator>
</id>
<discriminator column="CODE" type="string"/>
<one-to-one name="user" class="User" cascade="all" constrained="true"/>
</class>
--------------------------------------------------------------------------------
***********************
WebAddress.xml:
--------------------------------------------------------------------------------
<subclass name=" WebAddress " lazy="false" discriminator-value=" WebAddress" extends="Address">
<join table=" WebAddress">
<key><column name="USERID"/></key>
<property name="email" column="email" type="string" length="50" not-null="false" lazy="false"/>
</join>
</subclass>
--------------------------------------------------------------------------------
Note: Same code works if I do every thing in a single service method (retrieve, update, commit in the same current session & API). Not sure why it's disconnected on passing to client.
I'm using saveOrUpdate() API in my Bean.
I’m really stuck with this problem; I would appreciate your help!
Thanks, R.