• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null problem(java.sql.TimeStamp) for iBatis

 
Donald Fung
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using iBatis with oracle database. I found that if the database date field is null, the iBatis throws nullPointerException.

--- Check the result mapping for the 'activationDate' property.
--- Cause: com.ibatis.common.beans.ProbeException: Could not set property 'activationDate' for java.util.Hashtable. Cause: java.lang.NullPointerException

I search the JavaDoc and seems the java.sql.Timestamp/Date does not allow null value.

1) How to solve this? I can write more steps to convert it back into date but I would like to know if there is other solution...

2) Does Hibernate have the same problem?
[ April 11, 2007: Message edited by: Donald Fung ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1, in your query, you need to do something like NVL(myDate, someReallyOddDateThatNoRealRecordWouldEverHaveThatYouCanCheckFor)

Or have the database set that field to not allow nulls.

I am not sure if Hibernate has that issue.

Mark
 
Donald Fung
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your suggestion, Mark.

I had wrote a simple TypeHandler to convert the null field.
It returns null, which as a result that the iBatis set NULL in the returned Object.

Here it is:

[ April 27, 2007: Message edited by: Donald Fung ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic