-->
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.  [ 2 posts ] 
Author Message
 Post subject: What is allowed in UserType implementations?
PostPosted: Fri Apr 07, 2006 11:01 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1.2

We have a UserType that executes a session.get to replace the value of a property at load time. This seems to be causing problems with Hibernate. The following exception is thrown during a list() operation on an object containing this custom type, but we only see this exception when the UserType is doing session.get within nullSafeGet:

Code:
Caused by: java.sql.SQLException: Exhausted Resultset
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
   at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:382)
   at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
   at com.mchange.v2.c3p0.impl.NewProxyResultSet.getString(NewProxyResultSet.java:3472)
   at org.hibernate.type.StringType.get(StringType.java:18)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
   at xxx.yyy.usertype.DisplaySetValueType.nullSafeGet(DisplaySetValueType.java:91)


I can't find anywhere in the documentation where it says that you cannot access the Session from within a UserType's nullSafeGet methods (although this makes some degree of sense to avoid). Can someone please confirm that accessing a Session from within a UserType is not allowed? TIA ~


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 10, 2006 1:46 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You're allowed access a session, you're just not allowed use the session that you're currently reading a result set from, to get a new result set. This is not an hibernate restriction, it's a JDBC/DBMS one.

You can use a different session to do it. You can also use the current session to do things that don't touch reseult sets (e.g. isDirty, contains, etc.).

Your design sounds strange.. strange enough that I'll risk using the word "flawed". Why do you have to get a different object? Hibernate already does that sort of thing for you via associations. Changing objects on load risks causing unnecessary saves. And there are other reasons not to do this kind of thing. Have you looked for a different design, one that doesn't involve database accesses during database accesses?


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