-->
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.  [ 4 posts ] 
Author Message
 Post subject: exception setting property value CGLIB (Item.setProductId)
PostPosted: Thu Mar 02, 2006 6:55 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 3:26 am
Posts: 21
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
using swith spring


Mapping documents:

<?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>
<class name="org.springframework.samples.jpetstore.domain.Product" table="product" lazy="false">

<id name="productId" type="string" unsaved-value="null" >
<column name="productid" sql-type="varchar" not-null="true"/>
</id>
<property name="categoryId" column="category"/>
<property name="name" column="name"/>
<property name="description" column="descn" />
</class>

<class name = "org.springframework.samples.jpetstore.domain.Item" table = "item" lazy="false">
<id name="itemId" type="string" unsaved-value="null" >
<column name="itemid" sql-type="varchar" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<!-- <join table="inventory">
<key column="itemid" />
<property name="quantity" column="qty" />
</join>
-->

<!--<one-to-one name="product" class="org.springframework.samples.jpetstore.domain.Product"/>-->

<property name="supplierId" column="supplier"/>
<!--<property name="productId" column="productid" />-->

<many-to-one name="productId" class="org.springframework.samples.jpetstore.domain.Product" unique="true">
<column name="productid"/>
</many-to-one>

<!--<one-to-one name="productId" class="org.springframework.samples.jpetstore.domain.Product"/>-->





<property name="listPrice" column="listprice" />
<property name="unitCost" column="unitcost" />
<property name="status" />
<property name="attribute1" column="attr1"/>
<property name="attribute2" column="attr2"/>
<property name="attribute3" column="attr3"/>
<property name="attribute4" column="attr4"/>
<property name="attribute5" column="attr5"/>

</class>
</hibernate-mapping>



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

Full stack trace of any exception that occurs:

INFO: In ViewProductController.handleRequest::::
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.web.spring.ViewProductController handleRequest
INFO: ViewProductController.productId ::::::::::::FI-FW-01
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.web.spring.ViewProductController handleRequest
INFO: ViewCategoryController.category in handleRequest@ ::::::::::::
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.domain.logic.PetStoreImpl getItemListByProduct
INFO: In PetStoreImpl.getItemListByProduct:::: FI-FW-01
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.dao.hibernate.HibernateImplItemDao getItemListByProduct
INFO: In HibernateImplItemDao.getItemListByProduct(String productId) :::::::::::::
Hibernate: select item0_.itemid as itemid, item0_.supplier as supplier5_, item0_.productid as productid5_, item0_.listprice as listprice5_, item0_.unitcost as unitcost5_, item0_.status as status5_, item0_.attr1 as attr7_5_, item0_.attr2 as attr8_5_, item0_.attr3 as attr9_5_, item0_.attr4 as attr10_5_, item0_.attr5 as attr11_5_ from item item0_ where item0_.productid like 'FI-FW-01'
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.domain.Item <init>
INFO: In Item.getItemId:::: CONSTRUCTOR
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.domain.Item setItemId
INFO: In Item.setItemId:::: EST-4
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.domain.Item <init>
INFO: In Item.getItemId:::: CONSTRUCTOR
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.domain.Item setItemId
INFO: In Item.setItemId:::: EST-5
Hibernate: select product0_.productid as productid0_, product0_.category as category4_0_, product0_.name as name4_0_, product0_.descn as descn4_0_ from product product0_ where product0_.productid=?
In Product.setProductId::::::::FI-FW-01
In Product.setCategoryId::::::::FISH
In Product.setName::::::::Koi
In Product.setDescription::::::::<image src="../images/fish3.gif">Fresh Water fish from Japan
Mar 2, 2006 4:09:37 PM org.springframework.samples.jpetstore.domain.Item setSupplierId
INFO: In Item.setSupplierId::::
Mar 2, 2006 4:09:37 PM org.springframework.web.servlet.FrameworkServlet serviceWrapper
SEVERE: Could not complete request
org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of org.springframework.samples.jpetstore.domain.Item.setProductId; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of org.springframework.samples.jpetstore.domain.Item.setProductId
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of org.springframework.samples.jpetstore.domain.Item.setProductId
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:523)
at org.hibernate.loader.Loader.doQuery(Loader.java:429)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:211)
at org.hibernate.loader.Loader.doList(Loader.java:1588)
at org.hibernate.loader.Loader.list(Loader.java:1571)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:751)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:742)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:734)
at org.springframework.samples.jpetstore.dao.hibernate.HibernateImplItemDao.getItemListByProduct(HibernateImplItemDao.java:65)
at org.springframework.samples.jpetstore.domain.logic.PetStoreImpl.getItemListByProduct(PetStoreImpl.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy1.getItemListByProduct(Unknown Source)
at org.springframework.samples.jpetstore.web.spring.ViewProductController.handleRequest(ViewProductController.java:39)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:386)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:346)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)



Name and version of the database you are using:
mysql 4.0.1


The generated SQL (show_sql=true):

select item0_.itemid as itemid, item0_.supplier as supplier5_, item0_.productid as productid5_, item0_.listprice as listprice5_, item0_.unitcost as unitcost5_, item0_.status as status5_, item0_.attr1 as attr7_5_, item0_.attr2 as attr8_5_, item0_.attr3 as attr9_5_, item0_.attr4 as attr10_5_, item0_.attr5 as attr11_5_ from item item0_ where item0_.productid like 'FI-FW-01'

&

select product0_.productid as productid0_, product0_.category as category4_0_, product0_.name as name4_0_, product0_.descn as descn4_0_ from product product0_ where product0_.productid=?


Debug level Hibernate log excerpt:


Note I am getting data on these two independent queries.

But I am not able to get a join

I want this query to be generated


select item0_.itemid as itemid1_, item0_.supplier as supplier5_1_, item0_.productid as productid5_1_, item0_.listprice as listprice5_1_, item0_.unitcost as unitcost5_1_, item0_.status as status5_1_, item0_.attr1 as attr7_5_1_, item0_.attr2 as attr8_5_1_, item0_.attr3 as attr9_5_1_, item0_.attr4 as attr10_5_1_, item0_.attr5 as attr11_5_1_, product1_.productid as productid0_, product1_.category as category4_0_, product1_.name as name4_0_, product1_.descn as descn4_0_ from item item0_ left outer join product product1_ on item0_.productid=product1_.productid where item0_.itemid='EST-4'


I want to know what change must I do in the hbm to get this query.

Can any body help me out??

Regards,
Avinash

_________________
avinashb@cybage.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 7:07 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
In case you are using an hql query.. could you please post it?

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 7:12 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 3:26 am
Posts: 21
Hi ,

public Item getItem(String itemId) throws DataAccessException {
logger.info("In HibernateImplItemDao.getItem(String itemId):::::::::::::");
Item item = (Item) getHibernateTemplate().load(Item.class,itemId);
logger.info("HibernateImplItemDao.getItem:::::item.getproductId()======>"+item.getProductId());// getting productid here
logger.info("HibernateImplItemDao.getItem:::::item.getproduct()======>"+item.getProduct());// getting null here
if (item != null) {
logger.info("Item is not null");
}
else{
logger.info("Item is null");
}

return item;

}
}

This is the method getting called.
Hql query is in bold.

Regards,
Avinash

_________________
avinashb@cybage.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 10:08 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 3:26 am
Posts: 21
Hi all,

Myproblem is solved.

<many-to-one name="product" class="org.springframework.samples.jpetstore.domain.Product">
<column name="productid" />
</many-to-one>

This has to be put in the hbm.xml in the item tag

Regards
Avinash

_________________
avinashb@cybage.com


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