-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem with Hibernate.initialize and subclass
PostPosted: Thu Apr 22, 2004 6:34 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
I have a simple hiearchy where a Person object may have a Customer subclass. One of my objects stores a proxy to a Person, but the current actual entity should be a Customer. Some of my colleagues has put a Hibernate.initialize( person ) in the code, and this explodes with a cglib error on one of the properties.

Closely following what hibernate does in a debugger, I see that while being in SessionImpl.initializeEntity (2174), there is a call to persister.setPropertyValues which calls optimizer.setPropertyValues(object, values);

This is what bombs: the optimizer has a list of the fields that have to be set in the object: object is correctly of class Customer, and the list seems to have the correct setter names, but in the "values" array, there is one of the properties missing which should go in an int value: in fact, that property is null in the db. Does this mean that I can't initialize "int" properties with null NUMBER values in the db or is this related in some way to the subclass?

The error message is: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of it.esselunga.ecommerce.data.model.Customer.setHowManyRelatives; nested exception is net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of it.esselunga.ecommerce.data.model.Customer.setHowManyRelatives

(tried to set the use_reflection_optimizer property to false in hibernate.properties but nothing seems to change)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 6:37 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
NB: the hibernate.cglib.use_reflection_optimizer=false may not work maybe because I'm initializing hibernate through spring


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 6:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
int propertys can of course not be set to null, that just makes no sense. Map it as an Integer or use a custom UserType to map your database nulls.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 6:46 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
michael wrote:
int propertys can of course not be set to null, that just makes no sense. Map it as an Integer or use a custom UserType to map your database nulls.


Uhm. Ok, I thought there could be some sort of auto-conversion to 0. Thanks. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 6:47 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
immanuel wrote:
michael wrote:
int propertys can of course not be set to null, that just makes no sense. Map it as an Integer or use a custom UserType to map your database nulls.


Uhm. Ok, I thought there could be some sort of auto-conversion to 0. Thanks. ;)


As an additional note, in fact the property could not be set because I'm initializing hibernate through spring and it seems that property can only overridden in a hibernate.properties file loaded at class startup.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 6:47 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
immanuel wrote:
immanuel wrote:
michael wrote:
int propertys can of course not be set to null, that just makes no sense. Map it as an Integer or use a custom UserType to map your database nulls.


Uhm. Ok, I thought there could be some sort of auto-conversion to 0. Thanks. ;)


As an additional note, in fact the property could not be set because I'm initializing hibernate through spring and it seems that property can only overridden in a hibernate.properties file loaded at class startup.


(I am talking about the system property needed to disable cglib optimizer)


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