File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Null problem(java.sql.TimeStamp) for iBatis Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Null problem(java.sql.TimeStamp) for iBatis" Watch "Null problem(java.sql.TimeStamp) for iBatis" New topic
Author

Null problem(java.sql.TimeStamp) for iBatis

Donald Fung
Greenhorn

Joined: Oct 27, 2004
Posts: 18
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

Joined: Feb 05, 2001
Posts: 16622

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Donald Fung
Greenhorn

Joined: Oct 27, 2004
Posts: 18
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 ]
 
IntelliJ Java IDE
 
subject: Null problem(java.sql.TimeStamp) for iBatis
 
Threads others viewed
What is the representation in the code of dabase column TIMESTAMP's NULL value? iBatis, AS400
Comparing Dates with HQL
Storing date as null value in the backend using JDBC
iBatis and java.sql
Axis custom serializer
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture