Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one-to-many exception...

 
David Brock
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting really strange behavior with Hibernate (3.2.2). I've tried this with Oracle Express and Postgres 8.2, and my IDE is Eclipse 3.2.0
When I try and persist a one-to-many relationship I get the following exception:
java.lang.ClassCastException: java.lang.Boolean
at org.hibernate.type.SetType.wrap(SetType.java:39)
at org.hibernate.event.def.WrapVisitor.processArrayOrNewCollection(WrapVisitor.java:84)
at org.hibernate.event.def.WrapVisitor.processCollection(WrapVisitor.java:51)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.WrapVisitor.processValue(WrapVisitor.java:98)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.AbstractSaveEventListener.visitCollectionsBeforeSave(AbstractSaveEventListener.java:371)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:273)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
at com.agilewaves.ADAS.Event.EventManager.submitEvent(EventManager.java:87)
at com.agilewaves.ADAS.Event.EventManager.main(EventManager.java:805)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.dawidweiss.invoker.Invoker.loader(Invoker.java:167)
at com.dawidweiss.invoker.Invoker.main(Invoker.java:303)

What's interesting is that if I run the code in Eclipse it works fine, if I run it outside of eclipse using an exclipse generated JAR file I get the above exception. Three days earlier I had the opposite situation. It was failing in Eclipse and working stand-alone. As far as I know the only change was to add a new class for linear regression calculations.

Background:
I have two classes, Event and Data, Event has a 1 to many relationship with Data. The mapping files are:
<class name="com.agilewaves.ADAS.Event.Event" table="ADASEvent"
lazy="false">
<id type="int" name="ID" column="ID">
<generator class="sequence">
<param name="sequence">ADASEvent_seq</param>
</generator>
</id>
<property name="Name" column="Name" not-null="true" type="string"/>
<property name="Type" column="Type" not-null="true" type="int"/>
<property name="State" column="State" not-null="true" type="int"/>
<set name="Data" cascade="all,delete-orphan">
<key column="EventID"/>
<one-to-many class="com.agilewaves.ADAS.Event.Data"/>
</set>
</class>
For the Event and
<class name="com.agilewaves.ADAS.Event.Data" table="ADASData">
<id type="int" name="ID" column="ID">
<generator class="sequence">
<param name="sequence">ADASData_seq</param>
</generator>
</id>
<property name="Name" column="Name" not-null="true" type="string"/>
<property name="Value" column="Value" not-null="true"
type="string"/>
<property name="Units" column="Units" not-null="false"
type="string"/>
<property name="Datatype" column="Datatype" not-null="true"
type="int"/>
</class>
for the data.

Ofending code:
getSession().beginTransaction();
getSession().saveOrUpdate(ev);
getSession().commit();
close();

The Data attribute is defined as:
Set _data = new HashSet();

Any help would be most appreciated!

Thanks,

-David-

[ March 12, 2007: Message edited by: David Brock ]
[ March 12, 2007: Message edited by: David Brock ]
 
Assaf Nico
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Did you manage to find a solution to this problem? I am encounting something VERY similar.

Thanks

Assaf
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic