Hi all
I've tested this with Hibernate 2.1.1 and 2.1.2 and yielded the same result. The DB is Oracle 9.2.0.3.0.
What I've done is simply use session.load(Class, Serializable) to load an object and refresh it. I always get an exception, whether CGLIB is turned on or off. Without the refresh() call, the code works quite happily.
Attached, please find the first bit of my mapping file, the test java code and the complete console output. I apologise for not posting the entire mapping file as it's the company's property, but I can submit it to the Hibernate development team if it becomes necessary.
Thanks a lot.
---- Mapping file -----
<hibernate-mapping>
<class
name="com.savi.common.dr.ams.AssetImpl"
table="AMS_ASSET"
proxy="com.savi.common.dr.ams.AssetORInterface"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="assetId"
column="ASSET_ID"
type="long"
>
<generator class="sequence">
<param name="sequence">AMS_ASSET_ID_SQ</param>
</generator>
</id>
----- Java code -----
Session session = sessionFactory.openSession(DBConnection.getConnection());
Object o = session.load(AssetImpl.class, new Long(80300L));
System.out.println("KEVIN class " + o.getClass().getName() + ":" + o);
session.refresh(o);
----- Console -----
- 2004-03-08 06:07:00,112 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - opened session
- 2004-03-08 06:07:00,117 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - loading
[com.acme.common.dr.ams.AssetImpl#80300]
- 2004-03-08 06:07:00,123 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - attempting to resolve
[com.acme.common.dr.ams.AssetImpl#80300]
- 2004-03-08 06:07:00,124 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - object not resolved in any cache
[com.acme.common.dr.ams.AssetImpl#80300]
- 2004-03-08 06:07:00,124 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.persister.EntityPersister - Materializing entity:
[com.acme.common.dr.ams.AssetImpl#80300]
- 2004-03-08 06:07:00,129 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements,
0 open ResultSets
- 2004-03-08 06:07:00,131 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.SQL - select assetimpl0_.ASSET_ID as ASSET_ID0_,
assetimpl0_.ACTIVE_STATUS as ACTIVE_S2_0_, assetimpl0_.ACTIVITY_LOG_ID as
ACTIVITY3_0_, assetimpl0_.ASSET_DESCRIPTION as ASSET_DE4_0_,
assetimpl0_.ASSET_STATUS_ID as ASSET_ST5_0_, assetimpl0_.ATTR1 as ATTR10_,
assetimpl0_.ATTR2 as ATTR20_, assetimpl0_.COMP_ASSET_TYPE_ID as COMP_ASS8_0_,
assetimpl0_.CREATE_DATE_GMT as CREATE_D9_0_, assetimpl0_.CREATE_DATE_LOCAL as
CREATE_10_0_, assetimpl0_.CREATE_LOCAL_TZ as CREATE_11_0_,
assetimpl0_.CREATE_WHO as CREATE_WHO0_, assetimpl0_.CUSTOMER_ASSET_ID as
CUSTOME13_0_, assetimpl0_.DEFAULT_ATTRIBUTE_FLAG as DEFAULT14_0_,
assetimpl0_.FULFILLMENT_ID as FULFILL15_0_, assetimpl0_.GLOBAL_CODE as
GLOBAL_16_0_, assetimpl0_.GLOBAL_DESC as GLOBAL_17_0_, assetimpl0_.IMAGE_LINK
as IMAGE_LINK0_, assetimpl0_.IS_INSPECTED as IS_INSP19_0_,
assetimpl0_.IS_OPENED as IS_OPENED0_, assetimpl0_.IS_PUBLISHED as
IS_PUBL21_0_, assetimpl0_.IS_REFERENCED as IS_REFE22_0_, assetimpl0_.IS_SEALED
as IS_SEALED0_, assetimpl0_.LAST_LATITUDE as LAST_LA24_0_,
assetimpl0_.LAST_LINK_LOG_ID as LAST_LI25_0_, assetimpl0_.LAST_LONGITUDE as
LAST_LO26_0_, assetimpl0_.LAST_MODIFY_DATE_GMT as LAST_MO27_0_,
assetimpl0_.LAST_MODIFY_LOCAL_DATE as LAST_MO28_0_,
assetimpl0_.LAST_MODIFY_LOCAL_TZ as LAST_MO29_0_, assetimpl0_.LAST_MODIFY_WHO
as LAST_MO30_0_, assetimpl0_.LAST_RECORDED_TIME as LAST_RE31_0_,
assetimpl0_.LAST_RECORDED_ZONE_ID as LAST_RE32_0_,
assetimpl0_.LAST_ROUTE_LOG_ID as LAST_RO33_0_,
assetimpl0_.LAST_VALIDATED_ACTIVITY_LOG_ID as LAST_VA34_0_,
assetimpl0_.LINK_LOG_ID as LINK_LO35_0_, assetimpl0_.NEXT_ASSET_ID as
NEXT_AS36_0_, assetimpl0_.PARENT_ASSET_ID as PARENT_37_0_,
assetimpl0_.PERCENT_FULL as PERCENT38_0_, assetimpl0_.PLANNED_NEXT_ASSET_ID as
PLANNED39_0_, assetimpl0_.PLANNED_PARENT_ASSET_ID as PLANNED40_0_,
assetimpl0_.PLANNED_PRIOR_ASSET_ID as PLANNED41_0_, assetimpl0_.PRIOR_ASSET_ID
as PRIOR_A42_0_, assetimpl0_.ROUTE_LOG_ID as ROUTE_L43_0_,
assetimpl0_.SEAL_CODE as SEAL_CODE0_, assetimpl0_.VERSION_COUNT as
VERSION45_0_ from AMS_ASSET assetimpl0_ where assetimpl0_.ASSET_ID=?
- 2004-03-08 06:07:00,133 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.BatcherImpl - preparing statement
- 2004-03-08 06:07:00,135 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - binding '80300' to parameter: 1
- 2004-03-08 06:07:00,166 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.loader.Loader - processing result set
- 2004-03-08 06:07:00,167 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.loader.Loader - result row: 80300
- 2004-03-08 06:07:00,168 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 80300
- 2004-03-08 06:07:00,171 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.loader.Loader - Hydrating entity:
com.acme.common.dr.ams.AssetImpl#80300
- 2004-03-08 06:07:00,172 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning '1' as column: ACTIVE_S2_0_
- 2004-03-08 06:07:00,173 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning '82568' as column: ACTIVITY3_0_
- 2004-03-08 06:07:00,174 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning 'CUSHIONED BOX' as column:
ASSET_DE4_0_
- 2004-03-08 06:07:00,175 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.DoubleType - returning '10.0' as column: ASSET_ST5_0_
- 2004-03-08 06:07:00,176 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: ATTR10_
- 2004-03-08 06:07:00,177 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: ATTR20_
- 2004-03-08 06:07:00,177 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning '2' as column: COMP_ASS8_0_
- 2004-03-08 06:07:00,179 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.TimestampType - returning '04 March 2004 08:10:57' as
column: CREATE_D9_0_
- 2004-03-08 06:07:00,179 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.TimestampType - returning '04 March 2004 03:10:57' as
column: CREATE_10_0_
- 2004-03-08 06:07:00,180 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning 'EST' as column: CREATE_11_0_
- 2004-03-08 06:07:00,181 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning 'amsadmin' as column:
CREATE_WHO0_
- 2004-03-08 06:07:00,181 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning 'SLSIM-005' as column:
CUSTOME13_0_
- 2004-03-08 06:07:00,182 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning '1' as column: DEFAULT14_0_
- 2004-03-08 06:07:00,182 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.DoubleType - returning null as column: FULFILL15_0_
- 2004-03-08 06:07:00,183 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: GLOBAL_16_0_
- 2004-03-08 06:07:00,183 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: GLOBAL_17_0_
- 2004-03-08 06:07:00,193 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: IMAGE_LINK0_
- 2004-03-08 06:07:00,194 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: IS_INSP19_0_
- 2004-03-08 06:07:00,194 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning '0' as column: IS_OPENED0_
- 2004-03-08 06:07:00,195 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning '0' as column: IS_PUBL21_0_
- 2004-03-08 06:07:00,195 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning '0' as column: IS_REFE22_0_
- 2004-03-08 06:07:00,196 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning '10' as column: IS_SEALED0_
- 2004-03-08 06:07:00,196 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: LAST_LA24_0_
- 2004-03-08 06:07:00,196 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.DoubleType - returning null as column: LAST_LI25_0_
- 2004-03-08 06:07:00,196 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: LAST_LO26_0_
- 2004-03-08 06:07:00,197 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.TimestampType - returning null as column: LAST_MO27_0_
- 2004-03-08 06:07:00,197 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.TimestampType - returning null as column: LAST_MO28_0_
- 2004-03-08 06:07:00,197 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: LAST_MO29_0_
- 2004-03-08 06:07:00,197 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning 'amsadmin' as column:
LAST_MO30_0_
- 2004-03-08 06:07:00,197 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.TimestampType - returning '02 March 2004 00:00:00' as
column: LAST_RE31_0_
- 2004-03-08 06:07:00,198 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning '30020' as column: LAST_RE32_0_
- 2004-03-08 06:07:00,198 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.DoubleType - returning null as column: LAST_RO33_0_
- 2004-03-08 06:07:00,198 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning null as column: LAST_VA34_0_
- 2004-03-08 06:07:00,198 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.DoubleType - returning null as column: LINK_LO35_0_
- 2004-03-08 06:07:00,198 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning null as column: NEXT_AS36_0_
- 2004-03-08 06:07:00,198 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning null as column: PARENT_37_0_
- 2004-03-08 06:07:00,198 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.DoubleType - returning null as column: PERCENT38_0_
- 2004-03-08 06:07:00,199 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning null as column: PLANNED39_0_
- 2004-03-08 06:07:00,199 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning null as column: PLANNED40_0_
- 2004-03-08 06:07:00,199 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning null as column: PLANNED41_0_
- 2004-03-08 06:07:00,199 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning null as column: PRIOR_A42_0_
- 2004-03-08 06:07:00,199 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.DoubleType - returning null as column: ROUTE_L43_0_
- 2004-03-08 06:07:00,199 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.StringType - returning null as column: SEAL_CODE0_
- 2004-03-08 06:07:00,199 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.type.LongType - returning '0' as column: VERSION45_0_
- 2004-03-08 06:07:00,203 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.loader.Loader - done processing result set (1 rows)
- 2004-03-08 06:07:00,203 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0
open ResultSets
- 2004-03-08 06:07:00,203 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.BatcherImpl - closing statement
- 2004-03-08 06:07:00,203 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.loader.Loader - total objects hydrated: 1
- 2004-03-08 06:07:00,213 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - resolving associations for
[com.acme.common.dr.ams.AssetImpl#80300]
- 2004-03-08 06:07:00,214 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - loading
[com.acme.common.dr.ams.ActivityLogImpl#82568]
- 2004-03-08 06:07:00,214 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - loading
[com.acme.common.dr.cmm.CompAssetTypeImpl#2]
- 2004-03-08 06:07:00,214 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - loading
[com.acme.common.dr.cmm.ZoneImpl#30020]
- 2004-03-08 06:07:00,217 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,228 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,228 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,228 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,228 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,228 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,228 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,228 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - collection not cached
- 2004-03-08 06:07:00,247 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - done materializing entity
[com.acme.common.dr.ams.AssetImpl#80300]
- 2004-03-08 06:07:00,247 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - initializing non-lazy collections
KEVIN class
net.sf.hibernate.proxy.HibernateProxy$$EnhancerByCGLIB$$9f903f9:Asset assetId
= 80300
- 2004-03-08 06:07:00,250 - DEBUG - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.impl.SessionImpl - refreshing
[com.acme.common.dr.ams.AssetImpl#80300]
- 2004-03-08 06:07:00,254 - ERROR - ExecuteThread: '3' for queue: 'default' -
net.sf.hibernate.property.BasicPropertyAccessor - IllegalArgumentException in
class: com.acme.common.dr.ams.AssetImpl, getter method of property:
activeStatus
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred
calling getter of com.acme.common.dr.ams.AssetImpl.activeStatus
at
net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:110)
at
net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java:249)
at
net.sf.hibernate.impl.AbstractVisitor.process(AbstractVisitor.java:93)
at net.sf.hibernate.impl.SessionImpl.refresh(SessionImpl.java:2105)
at net.sf.hibernate.impl.SessionImpl.refresh(SessionImpl.java:2073)
at com.acme.dr.Test.test(Test.java:29)
at jsp_servlet._ams._jsp._test.__test._jspService(__test.java:88)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1075)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:418)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:462)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:20)
at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5534)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:685)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3155)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2519)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
Caused by: java.lang.IllegalArgumentException: object is not an instance of
declaring class
at java.lang.reflect.Method.invoke(Native Method)
at
net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96)
... 18 more
|