-->
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: Hibernate throws an exception ???
PostPosted: Wed Apr 07, 2004 11:34 am 
Newbie

Joined: Tue Mar 23, 2004 12:21 pm
Posts: 11
Hello All,
While trying to load a transient entity , hibernate is throwing an exception.
One of the field of java entity is of type long and the corresponding column in the database is of type NUMBER. If this coloumn in database is not null my code works fine, but if the value of this column is 'NULL' , hibernate throws me an exception , which is shown below:

--------------------------------------------------------------------------------------
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.xyx.managed.abc.entity.Testtbl.setEmpNo

-------------------------------------------------------------------------------------
EMPNO column in database is of type NUMBER(10) , it is represented by a long java primitive type in the corresponding java entity. If that particular column is NULL. I get the above exception. Also note that other columns of type VARCHAR2 (represented by String in corresponding java entity) pose no problems when their value is null in the database.

PS: EMPNO is not the primary key for this table.

Any help will be appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 11:40 am 
Regular
Regular

Joined: Wed Mar 03, 2004 9:38 am
Posts: 70
Yes, because long is a primitive type and not nullable. You can't set a long variable to null in your own Java code, so why should Hibernate be able to do it?

Either add a NOT NULL constraint to the column in the database, or use a nullable type in your Java code, such as Long.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 7:11 pm 
Newbie

Joined: Tue Mar 23, 2004 12:21 pm
Posts: 11
Thankyou , it worked ! :)


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.