-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: 3.3.0 - Merge Object with collection of Immutable Objs
PostPosted: Wed Sep 10, 2008 8:02 am 
Newbie

Joined: Mon Mar 13, 2006 2:03 pm
Posts: 3
Hibernate Version: 3.3.0

When I merge an object which contains a collection of objects which are immutable (mutable=false) I get an exception:

Caused by: java.lang.Throwable: Merged entity does not have status set to MANAGED; EntityEntry[ca.gc.csc_scc.model.bean.offender.purchase.Tax#10](READ_ONLY) status=READ_ONLY
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:97)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:704)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692)
at ca.gc.csc_scc.model.impl.dao.OffenderEffectDAO.savePurchaseOrder(OffenderEffectDAO.java:792)
at ca.gc.csc_scc.model.impl.service.OffenderEffectServiceImpl.savePurchaseOrder(OffenderEffectServiceImpl.java:445)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at ca.gc.csc_scc.model.util.ServiceFacadeInvocationHandler.invoke(ServiceFacadeInvocationHandler.java:118)
... 27 more


Here are the mapping files (I removed some <property> values to keep the size down).

Here is mapping for the object which is merged (bolded item matches second mapping file):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="ca.gc.csc_scc.model.bean.offender.purchase"
default-lazy="false">
<class name="POItem" table="opp_purchase_order_line_item" select-before-update="true" dynamic-update="true" optimistic-lock="version">
<id name = "id"
column = "line_item_id"
type = "ca.gc.csc_scc.model.impl.dao.hibernate.type.StringNumber" >
<generator class="native">
<param name="sequence">sq_opol</param>
</generator>
</id>
<version name="entityVersion" column="record_version" type="long"/>
<property name="modSigID" access="field" type="string" length="10" column="changed_by"/>
<component
name = "securitySignature"
class = "ca.gc.csc_scc.model.bean.UserSignature">
<property
name = "assignmentId"
column = "security_entered_by"
type = "string"
length = "10" />
<property
name = "date"
column = "security_entered_date"
type = "calendar" />
</component>
<idbag name="taxes" cascade="all" table="opp_item_sales_tax">
<collection-id type="long" column="item_sales_tax_id">
<generator class="sequence">
<param name="sequence">sq_oist</param>
</generator>
</collection-id>
<key column="line_item_id"/>
<many-to-many class="Tax" column="sales_tax_id"/>
</idbag>

</class>
</hibernate-mapping>


Here is the immutable object mapping:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="ca.gc.csc_scc.model.bean.offender.purchase"
default-lazy="false">
<class name="Tax" table="sales_tax" mutable="false">
<id name = "id"
column = "sales_tax_id"
type = "ca.gc.csc_scc.model.impl.dao.hibernate.type.StringNumber" >
<generator class="assigned"/>
</id>
<property
name = "taxRate"
column = "tax_rate"
type = "big_decimal" />
</class>
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.