-->
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.  [ 8 posts ] 
Author Message
 Post subject: Stored Procedures: Hibernate returns NullPointer Exception
PostPosted: Wed Nov 30, 2005 7:49 am 
Newbie

Joined: Tue Oct 18, 2005 2:51 am
Posts: 14
Location: Chennai, India
Hi everybody,

Anybody please help.

I am facing a big problem with return value of Stored Procedures. The procedure ( an Oracle function) returns a cursor. If any of the value within the cursor is having null value, there is a nullpointer exception raised from within Hibernate. I have checked with not-null ="true"/"false" in class. Unfortunately in named query itself, return property does not accept not null attribute.

First I thought it is an error for Oracle JDBC jar I am using. But when I used the same jar to make simple jdbc connection and execute the same thing, it posed no problem.

Thanks

With regards
Neil

I am ataching the Exception, if it comes to any help to diagnose the prob :

Exception in thread "main" java.lang.NullPointerException

at oracle.jdbc.ttc7.TTCAdapter.newTTCType(TTCAdapter.java:300)

at oracle.jdbc.ttc7.TTCAdapter.createNonPlsqlTTCColumnArray(TTCAdapter.java:270)

at oracle.jdbc.ttc7.TTCAdapter.createNonPlsqlTTCDataSet(TTCAdapter.java:231)

at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1937)

at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:880)

at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2516)

at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850)

at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)

at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:685)

at org.hibernate.dialect.Oracle9Dialect.getResultSet(Oracle9Dialect.java:309)

at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:127)

at org.hibernate.loader.Loader.getResultSet(Loader.java:1269)

at org.hibernate.loader.Loader.doQuery(Loader.java:391)

at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)

at org.hibernate.loader.Loader.doList(Loader.java:1593)

at org.hibernate.loader.Loader.list(Loader.java:1577)

at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)

at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)

at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)

at com.apl.gentrack.dao.HomeportDAO.getUserDetail_PROC(HomeportDAO.java:529)

at com.apl.gentrack.dao.HomeportDAO.main(HomeportDAO.java:639)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 7:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
its a nullpointer exception inside the driver when we call getResultSet() - that definitly looks to me like a bug in their driver...hibernate have not yet touched the data, it has just passed in the query.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 8:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
btw googling for this error result in many hits which is definitly not hibernate related...i suggest you go look at those hits first

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 9:00 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Also if you have access, try Oracle's Metalink (support site). You'll generally get much more accurate information there rather than Google.


Top
 Profile  
 
 Post subject: Where the problem is? Hibernate or Oracle
PostPosted: Wed Nov 30, 2005 9:20 am 
Newbie

Joined: Tue Oct 18, 2005 2:51 am
Posts: 14
Location: Chennai, India
Hi Max,

I always get helpful tips from you. But this time I I am getting a little bit puzzled. Actually as far as I know, we do not call the statement.getResultSet() directly for 'stored procedures returning cursors'. Rather, we cast it to ResultSet. But as you have said, it definitely looks like Hibernate is calling getResultSet method which I feel may not be the correct way.

Here is the code snippet I wrote for JDBC and running fine with existing jdbc jar.

session = getSession();

connection = session.connection();

Statement stmt = connection.prepareCall(QueryConstants.storedProcedureCallString);

//Returns Cursor
stmt.registerOutParameter(1, OracleTypes.CURSOR);


//All Input Parameters for the function

stmt.setString(2,origin_cd_in);

stmt.setString(3,port_location_cd_in);


stmt.execute();

ResultSet rs = (ResultSet)stmt.getObject(1);
// Procedure returns Cursor


If I am not wrong, I think you cannot run this program with getResultSet and definitely get a NullPointerException.


Waiting for your valuable comment

Regards
Neil


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 9:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
my bad - we actually do something similar as your code (see oracle9dialect), i just misread the stacktrace.

i is when we call ps.execute() it fails which again indicate to me a bug in the oracle driver....or at least a very buggy error handler in the driver.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 9:35 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
What version of the oracle driver are you using? Thick or thin driver?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 11:14 am 
Newbie

Joined: Tue Oct 18, 2005 2:51 am
Posts: 14
Location: Chennai, India
Hi Max,

The thing is that, the jdbcd code (given earlier) is working fine without complaint but Hibernate is throwing a long chain of errors. But I take your word, there may be something wrong in driver.

Hi PMularien,

I am using OJDBC14 (thin driver for Oracle 9.0 to 10). downloaded from Oracle site. Our Databse is Oracle 9i. If you have any suitable driver, could you please mail it to nil_ban@yahoo.co.uk

I am really at wit's end. I'll be grateful to get any assistance.

Thanks a lot

Regards
Neil


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