-->
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: Hibernate throws a PropertyAccessException
PostPosted: Fri Jan 20, 2006 2:55 am 
Newbie

Joined: Fri Dec 02, 2005 2:46 pm
Posts: 3
Hi,

When I try to assign a nullable database column to a primitive type, i am getting this "PropertyAccessException". But if i convert that to a wrapper type (i.e. from short to Short) then i am not getting any problem.

But i want to have primitive type in my POJO as it is easy for calculations. Is there a solution where i can have java primitive types in the POJO and still i can asign it to nillable database columns.

I am also providing all the necessary data for your reference.

Thanks in advance
Rama Krishna K


Hibernate version:3.1.1
Name and version of the database :Oracle 9i

Mapping document:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.xyz.abc.dataservices.customer.to.Customer" table="CUSTOMER" >
<id name="cstCustid" type="string">
<column name="CST_CUSTID" length="12" />
<generator class="assigned" />
</id>
<property name="cstRole" type="short">
<column name="CST_ROLE" />
</property>
<property name="cstBpType" type="short">
<column name="CST_BP_TYPE" />
</property>
<property name="cstBpStatus" type="short">
<column name="CST_BP_STATUS" />
</property>
<property name="cstSalutation" type="short">
<column name="CST_SALUTATION" />
</property>
<property name="cstFirstName" type="string">
<column name="CST_FIRST_NAME" />
</property>
<property name="cstPaternalLastName" type="string">
<column name="CST_PATERNAL_LAST_NAME" />
</property>
<property name="cstMaternalLastName" type="string">
<column name="CST_MATERNAL_LAST_NAME" />
</property>
<property name="cstNationality" type="string">
<column name="CST_NATIONALITY" />
</property>
<property name="cstDateOfBirth" type="date">
<column name="CST_DATE_OF_BIRTH" />
</property>
<property name="cstGender" type="short" >
<column name="CST_GENDER" not-null="false" default="0"/>
</property>
<property name="cstMaritalStatus" type="short" >
<column name="CST_MARITAL_STATUS" not-null="false" default="0"/>
</property>
<property name="cstMarriageType" type="short">
<column name="CST_MARRIAGE_TYPE" not-null="false" default="0"/>
</property>
<property name="cstProfession" type="short">
<column name="CST_PROFESSION" not-null="false" default="0"/>
</property>
<property name="cstLineOfBusiness" type="string">
<column name="CST_LINE_OF_BUSINESS" />
</property>
<property name="cstBpVer" type="short">
<column name="CST_BP_VER" not-null="false" default="0"/>
</property>
<property name="cstRut" type="string">
<column name="CST_RUT" />
</property>
</class>
</hibernate-mapping>



Full stack trace of the exception:
org.apache.jasper.JasperException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.tcs.pdn.dataservices.customer.to.CstCustomer.setCstGender
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.tcs.pdn.dataservices.customer.to.CstCustomer.setCstGender
org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:215)
org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:185)
org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232)
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:126)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
org.hibernate.loader.Loader.doQuery(Loader.java:717)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.doList(Loader.java:2150)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:298)
org.apache.jsp.NewCustomers_jsp._jspService(NewCustomers_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 5:10 am 
Newbie

Joined: Wed Dec 14, 2005 6:50 am
Posts: 17
Which jdk do you use?
If you use jdk 1.5, your "easy for calculations" is no problem since:

Code:
Integer myInt = 5;
myInt += 10;
System.out.println(myInt); // = 15


works with no problem...

Hope this helps! Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 5:23 am 
Newbie

Joined: Fri Dec 02, 2005 2:46 pm
Posts: 3
Hey Orome,

Thanks for the reply.

I am using JDK1.4 and unfartunately we can shift to JDK1.5.
Is there a solution other than changing all primitive types in POJO to wrappers when using JDK1.4?

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 8:03 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Use "DEFAULT" in DDL or transform values using custom type if "default" is application specific (see standard implementation for example).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 7:02 am 
Newbie

Joined: Fri Dec 02, 2005 2:46 pm
Posts: 3
Hi baliukas,

Can you explain me the solution again clearly. I am new to hibernate.

Thanks


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.