-->
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.  [ 2 posts ] 
Author Message
 Post subject: exception setting property value with CGLIB
PostPosted: Fri Feb 11, 2005 7:38 am 
Newbie

Joined: Fri Feb 11, 2005 7:21 am
Posts: 3
I'm getting this exception when I try to recover an object from DB which has a null column:

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="es.tid.psstlatam.api.ags.AGSNavigationPlan" table="SI_TF_NAVIGATION_PLANS">

<id name="id" type="long" column="PLAN_ID">
<generator class="assigned"/>
</id>

<property name="name"/>
<property name="description"/>
<property name="commercialModel" column="COMMERCIAL_MODEL"/>
<property name="pin"/>

</class>

</hibernate-mapping>


public class AGSNavigationPlan implements Serializable {

private long id = 0;

private String name = null;

private String description = null;

private boolean pin = false;

private byte commercialModel = 0;

/**********************************************************************************************/

public long getId(){
return id;
}

public void setId(long id){
this.id=id;
}

public String getName(){
return name;
}

public void setName(String name){
this.name=name;
}

public String getDescription(){
return description;
}

public void setDescription(String description){
this.description=description;
}

public byte getCommercialModel(){
return commercialModel;
}

public void setCommercialModel(byte commercialModel){
this.commercialModel=commercialModel;
}

public boolean getPin(){
return pin;
}

public void setPin(boolean pin){
this.pin=pin;
}


Code between sessionFactory.openSession() and session.close():

Query queryNavigationPlans=hibSession.createQuery("from AGSNavigationPlan np order by np.id");
List dbNavigationPlansList=queryNavigationPlans.list();

if (dbNavigationPlansList.size()==0)
{
hibSession.close();
throw new AGSException(AGSException.NO_NAVIGATION_PLANS, "There are no navigation plans");
}

Object[] dbNavigationPlansArray=dbNavigationPlansList.toArray();
Set dbNavigationPlansSet=new HashSet();

for (int i=0; i<dbNavigationPlansArray.length; i++)
{
AGSNavigationPlan navigationPlan=(AGSNavigationPlan)dbNavigationPlansArray[i];
dbNavigationPlansSet.add(navigationPlan);
}

if (dbNavigationPlansSet.size()==0)
{
hibSession.close();
throw new AGSException(AGSException.NO_NAVIGATION_PLANS, "There are no navigation plans");
}

Full stack trace of any exception that occurs:

?DEBUG [api.ags]: Hibernate Session Factory initialized
?Hibernate: select agsnavigat0_.PLAN_ID as PLAN_ID, agsnavigat0_.name as name, agsnavigat0_.description as descript3_, agsnavigat0_.COMMERCIAL_MODEL as COMMERCI4_, agsnavigat0_.pin as pin from SI_TF_NAVIGATION_PLANS agsnavigat0_ order by agsnavigat0_.PLAN_ID
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of es.tid.psstlatam.api.ags.AGSNavigationPlan.setCommercialModel
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:212)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2206)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at es.tid.psstlatam.api.ags.AGSDelegate.listNavigationPlans(AGSDelegate.java:77)
at es.tid.psstlatam.api.ags.AGSTests.listNavigationPlans(AGSTests.java:69)
at es.tid.psstlatam.api.ags.AGSTests.main(AGSTests.java:21)
Caused by: net.sf.cglib.beans.BulkBeanException
at es.tid.psstlatam.api.ags.AGSNavigationPlan$$BulkBeanByCGLIB$$ccadffc4.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:207)
... 11 more
Caused by: java.lang.NullPointerException
... 13 more
There was an exception: es.tid.psstlatam.api.ags.AGSException: Problems with the DB session: net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of es.tid.psstlatam.api.ags.AGSNavigationPlan.setCommercialModel

Name and version of the database you are using:

Oracle 9


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 7:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
primitive types can't be set to null - either use an object property (Long, Boolean, etc.) or write a custom UserType remapping the nulls to some default value.


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