-->
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.  [ 6 posts ] 
Author Message
 Post subject: Getting a ClassCastException with one-to-one
PostPosted: Wed Feb 09, 2005 8:46 pm 
Beginner
Beginner

Joined: Mon Dec 08, 2003 12:15 am
Posts: 47
I have a one-to-one relationship and I keep on getting a ClassCastException whenever the relation gets loaded.

Anybody has any idea why after looking at the info below

Thanks in advance

Hibernate version:
2.18


Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="com.uaig.migration.history.as400.vo.Unit"
table="UQXXUNIT"
dynamic-update="false"
dynamic-insert="false"
>

<composite-id
name="unitPK"
class="com.uaig.migration.history.as400.vo.UnitPK"
>
<key-property
name="referenceNumber"
type="java.lang.Integer"
column="UUREFNO"
/>

<key-property
name="unitNumber"
type="java.lang.Integer"
column="UUNITNO"
/>
</composite-id>

<property
name="companyNumber"
type="com.uaig.migration.hibernate.CustomStringTrimType"
column="UUCOMP#"
/>

<property
name="policyPrefix"
type="com.uaig.migration.hibernate.CustomStringTrimType"
column="UUPRFXN"
/>

<property
name="policyNumber"
type="java.lang.Integer"
column="UUPLNBR"
/>

<property
name="unitType"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUNITTY"
length="2"
/>

<property
name="unitGroup"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUNITGR"
length="2"
/>

<property
name="vinId"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUVINID"
length="25"
/>

<property
name="unitYear"
type="java.lang.Integer"
update="true"
insert="true"
column="UUYEAR"
length="4"
/>

<property
name="unitMake"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUMAKE"
length="4"
/>

<property
name="unitModel"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUMODL"
length="10"
/>

<property
name="description"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUDESC"
length="30"
/>

<property
name="garageZipCode"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUZIPC"
length="9"
/>

<property
name="countyName"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUCNTY"
length="20"
/>

<property
name="cityName"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUCITY"
length="20"
/>

<property
name="countyCode"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUCNTCD"
length="5"
/>

<property
name="unitStatus"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUSTUS"
length="1"
/>

<property
name="unitActivity"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUACTY"
length="1"
/>

<property
name="mileToWork"
type="java.lang.Integer"
update="true"
insert="true"
column="UUMILE"
length="3"
/>

<property
name="deleteDate"
type="java.util.Date"
update="true"
insert="true"
column="UUDELDT"
length="7"
/>

<property
name="addDate"
type="java.util.Date"
update="true"
insert="true"
column="UUADDDT"
length="7"
/>

<property
name="ratedClass"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UURCLS"
length="6"
/>

<property
name="odometerReading"
type="java.lang.Integer"
update="true"
insert="true"
column="UUODOM"
length="7"
/>

<property
name="ratedSymbol"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UURSYMB"
length="2"
/>

<property
name="useCode"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUPUSEC"
length="2"
/>

<property
name="territory"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUTERR"
length="3"
/>

<property
name="passiveRest"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUPSRT"
length="2"
/>

<property
name="antiTheft"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUANTF"
length="2"
/>

<property
name="antiLock"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUANTLK"
length="2"
/>

<property
name="multiCar"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUMULTC"
length="1"
/>

<property
name="transferDiscount"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUTRNFD"
length="1"
/>

<property
name="ratedPDriver"
type="java.lang.Integer"
update="true"
insert="true"
column="UURTDRV"
length="3"
/>

<property
name="replacementCost"
type="java.lang.Integer"
update="true"
insert="true"
column="UURPLCT"
length="7"
/>

<property
name="customEquipment"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUCUSTE"
length="2"
/>

<property
name="highSymbolSurch"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUHGSYM"
length="2"
/>

<property
name="goodSafeDriver"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUSNRDR"
length="1"
/>

<property
name="unitChange"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUNITCH"
length="1"
/>

<property
name="vinChange"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UUVINCH"
length="1"
/>


<one-to-one name="leanHolder"
class="com.uaig.migration.history.as400.vo.LeanHolderInfo"
cascade="save-update"/>
</class>
</hibernate-mapping>

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="com.uaig.migration.history.as400.vo.LeanHolderInfo"
table="UQXXADLX"
dynamic-update="false"
dynamic-insert="false"
>

<composite-id
name="leanHolderPk"
class="com.uaig.migration.history.as400.vo.LeanHolderPK"
>
<key-property
name="referenceNumber"
type="java.lang.Integer"
column="UAREFNO"
/>
<key-property
name="unitNumber"
type="java.lang.Integer"
column="UAUNTNO"
/>
</composite-id>

<property
name="addInterestCode"
type="java.lang.Integer"
column="UAAICOD"
/>

<property
name="companyNumber"
type="com.uaig.migration.hibernate.CustomStringTrimType"
column="UACOMP#"
length="2"
/>

<property
name="policyPrefix"
type="com.uaig.migration.hibernate.CustomStringTrimType"
column="UAPRFXN"
length="4"
/>

<property
name="policyNumber"
type="java.lang.Integer"
column="UAPLNBR"
length="9"
/>

<property
name="ketFldFromWeb"
type="java.lang.Integer"
update="true"
insert="true"
column="UAKEYFL"
length="9"
/>

<property
name="addInterestTy"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAADNTT"
length="1"
/>

<property
name="loanNumber"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UALOANN"
length="20"
/>

<property
name="addDate"
type="java.util.Date"
update="true"
insert="true"
column="UAADDDT"
length="7"
/>

<property
name="delDate"
type="java.util.Date"
update="true"
insert="true"
column="UADELDT"
length="7"
/>

<property
name="addIntName"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAINAME"
length="30"
/>

<property
name="addIntAddress1"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAIADD1"
length="30"
/>

<property
name="addIntAddress2"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAIADD2"
length="30"
/>

<property
name="addIntCity"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAICITY"
length="20"
/>

<property
name="addIntState"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAISTAT"
length="2"
/>

<property
name="addIntZipCode"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAIZIPC"
length="2"
/>

<property
name="addIntPhone"
type="java.lang.Integer"
update="true"
insert="true"
column="UAIPHN#"
length="10"
/>

<property
name="addIntFax"
type="java.lang.Integer"
update="true"
insert="true"
column="UAIFAX#"
length="10"
/>

<property
name="addIntChange"
type="com.uaig.migration.hibernate.CustomStringTrimType"
update="true"
insert="true"
column="UAADLCH"
length="1"
/>

<one-to-one name="unit"
class="com.uaig.migration.history.as400.vo.Unit"
constrained="true">
</one-to-one>

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
UnitPK pk = new UnitPK();
pk.setReferenceNumber(new Integer(600100));
pk.setUnitNumber(new Integer(1));
Query qq = as400Session.createQuery("select unit from Unit unit where unit.unitPK.referenceNumber = 600100");
Unit un = (Unit)qq.list().get(0);

Full stack trace of any exception that occurs:
ERROR [main] (BaseMigration.java:50) - Handling Exception...Please consult stacktrace:
net.sf.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of com.uaig.migration.history.as400.vo.LeanHolderPK.?
at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:192)
at net.sf.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:164)
at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:151)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:753)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:793)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:271)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:947)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:966)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:413)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2131)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2001)
at net.sf.hibernate.impl.SessionImpl.internalLoadOneToOne(SessionImpl.java:1955)
at net.sf.hibernate.type.OneToOneType.resolveIdentifier(OneToOneType.java:72)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:208)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2219)
at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:319)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:309)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1064)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at com.uaig.migration.dao.BaseDAO.findSavePoliciesForHistoryInitialImport(BaseDAO.java:280)
at com.uaig.migration.core.EndorsementHistoryMigration.run(EndorsementHistoryMigration.java:27)
at com.uaig.migration.core.EndorsementHistoryMigration.main(EndorsementHistoryMigration.java:17)
Caused by: java.lang.ClassCastException
at com.uaig.migration.history.as400.vo.LeanHolderPK$$BulkBeanByCGLIB$$c859a9f2.getPropertyValues(<generated>)
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java:48)
at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:189)
... 28 more

Name and version of the database you are using:
DB2/AS400

The generated SQL (show_sql=true):
Look at stacktrace above

Debug level Hibernate log excerpt:
Look at stacktrace above


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 9:27 am 
Newbie

Joined: Wed Sep 01, 2004 9:04 am
Posts: 18
Location: Enschede, Netherlands
Try using the same PK class for both classes.


Top
 Profile  
 
 Post subject: did you ever fix your problem
PostPosted: Mon Apr 18, 2005 7:52 pm 
Newbie

Joined: Mon Apr 18, 2005 7:35 pm
Posts: 1
juan110470, did you ever fix your problem ...I am having the same issue and would appreciate any help

- xc


Top
 Profile  
 
 Post subject: Re: did you ever fix your problem
PostPosted: Tue Apr 19, 2005 9:15 am 
Beginner
Beginner

Joined: Mon Dec 08, 2003 12:15 am
Posts: 47
I never quite fixed the problem. A colleague of mine was working on practically the same set of mapping files but for a different application and what I wound up doing is using his and the problem got solved. The strange part is that his mapping files and mine were identical. I am sure somewhere there must have been something that I missed.

I am sorry I can't help you any further than this.

Good luck


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 19, 2005 10:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
do as the exception says and find out what property does not have the right type.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: ClassCastException
PostPosted: Mon Feb 27, 2006 3:50 am 
Newbie

Joined: Sun Oct 24, 2004 6:37 am
Posts: 2
I am getting same exception...I am not able to enable the
use hibernate.cglib.use_reflection_optimizer as we are using mbeans in jboss as given below. How to use this hibernate property in jboss? I tried using ReflectionOptimizationEnabled as per jboss admin guide. But it says attribute not found. I am using jboss 3.0

<server>
<mbean code="net.sf.hibernate.jmx.HibernateService"
name="jboss.jca:service=TAPHibernateFactory,
name=TAPHibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=TeradataDS</depends>
<!-- Make it deploy ONLY after DataSource had been started -->

<attribute name="JndiName">java:/TAP/HibernateFactory/TeradataDS</attribute>
<attribute name="Datasource">java:/TeradataDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.TeradataDialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">java:/UserTransaction</attribute>
<attribute name="CacheProvider">net.sf.hibernate.cache.TreeCacheProvider</attribute>
<!-- Mapping files -->


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

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.