-->
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.  [ 3 posts ] 
Author Message
 Post subject: nullSafeSet and nullSafeGet methods not getting called
PostPosted: Wed Feb 06, 2008 8:42 am 
Newbie

Joined: Wed Feb 06, 2008 8:28 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.3.ga

Name and version of the database you are using: HSQL

I have implemented a UserType which I intend to use on a String property.

However I ran into and issue where the nullSafeGet and the nullSafeSet methods get called only if the entity has an @Id field with the @GeneratedValue annotation.

here's how i use the type

class Identity {
@Id
private Long id;

@Type(type="x.x.XType")
private String name;
}

When i save the class mentioned above the nullSafeSet and the nullSafeGet method in XType does not get executed when i persist the object.

change it to

class Identity {
@Id
@GeneratedValue
private Long id;

@Type(type="x.x.XType")
private String name;
}
and it works fine


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 4:38 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
In the first case, what does happen when you persist? You won't be able to save an instance of that first class without assigning an ID.

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 9:32 pm 
Newbie

Joined: Wed Feb 06, 2008 8:28 am
Posts: 2
We set the id field ourselves.
In the code that we use the id field is a string called "code" we assign a value to this before saving.


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