aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate: ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: ClassCastException" Watch "Hibernate: ClassCastException" New topic
Author

Hibernate: ClassCastException

Tiago Fernandez
Ranch Hand

Joined: May 16, 2003
Posts: 167
Hi everybody,

I'm having problems while trying to update a table that have 2 children (one-to-one map for both):

java.lang.ClassCastException at net.sf.hibernate.type.LongType.set(LongType.java:35)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:749)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:788)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.loadByUniqueKey(EntityLoader.java:55)
at net.sf.hibernate.persister.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1117)
at net.sf.hibernate.impl.SessionImpl.loadByUniqueKey(SessionImpl.java:3897)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:207)
at net.sf.hibernate.type.EntityType.copy(EntityType.java:113)
at net.sf.hibernate.type.TypeFactory.copy(TypeFactory.java:284)
at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:4091)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:4029)
at br.atech.foundation.persistence.hibernate.AbstractHibernatePersistenceManager.update(AbstractHibernatePersistenceManager.java:349)


Check out my hbm.xml:

<class
name="xyz.Editor"
table="EDITOR"
>

<id
name="id"
type="java.lang.Long"
column="ID"
>
<generator class="increment" />
</id>

<!-- associations -->
<!-- bi-directional one-to-one association to EditorText -->
<one-to-one
name="editorText"
class="xyz.EditorText"
outer-join="auto"
property-ref="editor"
cascade="all"
/>
<!-- bi-directional one-to-one association to EditorImage -->
<one-to-one
name="editorImage"
class="xyz.EditorImage"
outer-join="auto"
property-ref="editor"
cascade="all"
/>

</class>

...

<class
name="xyz.EditorImage"
table="EDITOR_IMAGE"
>

<id
name="id"
type="java.lang.Long"
column="ID"
>
<generator class="increment" />
</id>

<property
name="image"
type="binary"
column="IMAGE"
/>

<!-- associations -->
<!-- bi-directional one-to-one association to Editor -->
<many-to-one
name="editor"
class="xyz.Editor"
unique="true"
>
<column name="EDITOR_ID" />
</many-to-one>

</class>

...

<class
name="xyz.EditorText"
table="EDITOR_TEXT"
>

<id
name="id"
type="java.lang.Long"
column="ID"
>
<generator class="increment" />
</id>

<property
name="text"
type="binary"
column="TEXT"
/>

<!-- associations -->
<!-- bi-directional one-to-one association to Editor -->
<many-to-one
name="editor"
class="xyz.Editor"
unique="true"
>
<column name="EDITOR_ID" />
</many-to-one>

</class>

Can you help me, please!?

Thx


Tiago Fernandez
http://www.tiago182.spyw.com/
Tiago Fernandez
Ranch Hand

Joined: May 16, 2003
Posts: 167
That bug was nasty.

I just solved the problem getting rid of <property-ref="editor"> in one-to-one mappings.

Thx anyways!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate: ClassCastException