wood burning stoves 2.0
The moose likes Object Relational Mapping and the fly likes inserting NULL with iBatis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "inserting NULL with iBatis" Watch "inserting NULL with iBatis" New topic

inserting NULL with iBatis

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I have a simple mapping using a parameterClass :
<insert id="insertTest" parameterClass="mypackage.MyClass">

I'm not sure how to deal with NULL values in MyClass.
What I do now is using isNotNull and isNull tags like :
<isNotNull property="myproperty">
<isNull property="myproperty">

This is ugly. Is there a better way to deal NULLs ?
I know I could use parameterMap instead of parameterClass but it does not seem to be recommended.

[My Blog]
All roads lead to JavaRanch
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

In your MyClass, you could have primitive types for non-nullable fields and object types for nullable fields. Is this what you are looking for?

P.S: I havent used iBatis before, so my answer might be way off mark.

[My Blog] [JavaRanch Journal]
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

No, that's not the problem. But thank you for helping.

I've got it. Specifying the jdbcType after the propertyName will do.
Like #myproperty:VARCHAR#.
I agree. Here's the link: http://aspose.com/file-tools
subject: inserting NULL with iBatis
It's not a secret anymore!