-->
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.  [ 3 posts ] 
Author Message
 Post subject: ClassCastException at Transaction.commit(): Using Pointbase
PostPosted: Wed Jun 02, 2004 7:38 pm 
Newbie

Joined: Wed Jun 02, 2004 7:06 pm
Posts: 8
Hello...I am using Hibernate 2.1.3 over Pointbase 4.8. I am trying to persist an existing JavaBean value object class, so I wrote a .hbm.xml file after the fact. I did make the Java Bean Serializable, and added the toString(), hashCode(), and equals(Object other) that Hibernate would have generated from the .hbm.xml (based on code I saw in the O Reilly book.) In the .hbm.xml file I have tried both id generator class="native" and generator class="assigned".

Java code: The first line of interest is session.beginTransaction(). I create three instances of my class in a loop, calling session.save(...) each time.

After the loop completes, I call session.flush() and transaction.commit(). I then get a ClassCastException; here it is in context. In debug I can see that my class instance data members are populated, including the id. Has anyone seen this to know where I should look to correct this? Thank you.

17:15:56,498 DEBUG SessionImpl:2259 - Flushed: 3 insertions, 0 updates, 0 deletions to 3 objects
17:15:56,508 DEBUG SessionImpl:2264 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
17:15:56,508 DEBUG Printer:75 - listing entities:
java.lang.ClassCastException
at net.sf.hibernate.type.StringType.toString(StringType.java:47)
at net.sf.hibernate.type.NullableType.toString(NullableType.java:78)
at net.sf.hibernate.impl.Printer.toString(Printer.java:49)
at net.sf.hibernate.impl.Printer.toString(Printer.java:82)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2270)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228)
at com.test.dao.TestHibernate.main(TestHibernate.java:50)
17:15:56,559 DEBUG SessionImpl:560 - closing session
17:15:56,559 DEBUG SessionImpl:3327 - disconnecting session
17:15:56,559 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
17:15:56,559 INFO SessionFactoryImpl:531 - closing
17:15:56,559 INFO DriverManagerConnectionProvider:143 - cleaning up connection pool: jdbc:pointbase:embedded:TestDB;database.home=c:/Test/TestDB
17:15:56,599 DEBUG CacheManager:182 - Attempting to create an existing instance. Existing instance returned.
17:15:56,599 DEBUG CacheManager:182 - Attempting to create an existing instance. Existing instance returned.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 7:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You have a property mapped as String which is not a string.


Top
 Profile  
 
 Post subject: Thanks - you were right on.
PostPosted: Thu Jun 03, 2004 10:12 am 
Newbie

Joined: Wed Jun 02, 2004 7:06 pm
Posts: 8
Dear Michael, thank you so much for your helpful tip. My Java Bean has 48 member variables and #46 is "short" and I specified "string" in the "hbm.xml" file. Typical new-person mistake I suppose and I just did not see it. Thank you for getting me on my way.

Sincerely,

David


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.