-->
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.  [ 5 posts ] 
Author Message
 Post subject: null values in primitive types
PostPosted: Fri Sep 12, 2003 5:24 am 
Newbie

Joined: Fri Sep 12, 2003 4:58 am
Posts: 7
Hello,

I'm getting PropertyAccessException "Null value was assigned to a property of primitive type" when I try to use session.find.

I have primitive-type members in my java classes, and related fields in the database tables can have null values.

I wonder is this allowed or not?
and if it's not allowed the only way to overcome this problem is to convert primitive fields to wrapper types (e.g. long to Long). (I cannot change database structure for now) Right?

Regards...

Serkan Soykan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 5:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is not allowed.

You can solve the problem using a UserType, however.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:02 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
i solved the problem by using java types (Long and Integer) for the primitive counterparts long and int. If you allow NULLs in the DB then you are best not to use primitive types in the app code.


Top
 Profile  
 
 Post subject: null values in primitive types
PostPosted: Fri Sep 12, 2003 2:35 pm 
Newbie

Joined: Fri Sep 12, 2003 1:44 pm
Posts: 15
Gerrick and Gavin, thank you for your fast response.

As Derrick suggested, we modified our hbm files and classes with java.lang.* types (java.lang.Long instead of long). Now we can retrieve records with null fields.

However, since our application will be big and we'll have lots of simultaneous users and batch processes accessing the db and creating lots of objects, we're afraid the large number of class instances will take lot more memory when the properties are declared as objects, instead of primitive types. This might be an issue about our application's memory requirements.

We're new to hibernate and object based programming (we live in a relational world), so some our concerns might sound trivial. Do you think the above comments are correct ?

Regards,
Bulent Erdemir


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually primitive types are *less* efficient in Hibernate.

And if you are running under a modern JVM, just don't worry about these kinds of issues. Let _me_ worry about that kind of performance tuning.

You just need to worry about accessing *data* efficiently.


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