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: UserType for Java primitives
PostPosted: Tue Jul 13, 2004 12:24 pm 
Newbie

Joined: Thu Jun 24, 2004 1:45 am
Posts: 1
I understand that if you have nullable columns in the database that are mapped to primitives, you need to use a UserType to assign default values if the database column is null.

Implementing UserType for any classes are easy, however the required methods for the interface requires Object parameters (as shown below), and I am at a loss on how to implement this for primitives.

Code:
  public boolean equals(Object x, Object y) throws HibernateException
  {
    return false;
  }

  public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
  {
    return null;
  }

  public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
  {
   
  }

  public Object deepCopy(Object value) throws HibernateException
  {
    return null;
  }


Should I implement these to accept the Integer wrapper if I want to use it on an int?

Does anyone have any idea what I should do here, or have an example?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 4:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Yes, use the wrapper class


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.