Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="jpetstore.hibernate.Lineitem"
table="lineitem"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="lineitem"
</meta>
<composite-id name="comp_id" class="jpetstore.hibernate.LineitemPK">
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="orderid"
column="orderid"
type="java.lang.Integer"
length="11"
>
<meta attribute="field-description">
@hibernate.property
column="orderid"
length="11"
</meta>
</key-property>
<key-property
name="linenum"
column="linenum"
type="java.lang.Integer"
length="11"
>
<meta attribute="field-description">
@hibernate.property
column="linenum"
length="11"
</meta>
</key-property>
</composite-id>
<property
name="itemid"
type="java.lang.String"
column="itemid"
not-null="true"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="itemid"
length="10"
not-null="true"
</meta>
</property>
<property
name="quantity"
type="int"
column="quantity"
not-null="true"
length="11"
>
<meta attribute="field-description">
@hibernate.property
column="quantity"
length="11"
not-null="true"
</meta>
</property>
<property
name="unitprice"
type="java.math.BigDecimal"
column="unitprice"
not-null="true"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="unitprice"
length="10"
not-null="true"
</meta>
</property>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
ar 21, 2006 11:19:18 AM org.springframework.samples.jpetstore.web.spring.AddItemToCartController handleRequest
NFO: In AddItemToCartController.handleRequest::::
ar 21, 2006 11:19:18 AM org.springframework.samples.jpetstore.web.spring.AddItemToCartController handleRequest
NFO: AddItemToCartController.cart========>>jpetstore.hibernate.Cart@be7667
ar 21, 2006 11:19:18 AM org.springframework.samples.jpetstore.web.spring.AddItemToCartController handleRequest
NFO: workingItemId:::::::::::::::::::: EST-19
ar 21, 2006 11:19:18 AM jpetstore.hibernate.Cart containsItemId
NFO: In Cart.containsItemId:::: false
ar 21, 2006 11:19:18 AM org.springframework.samples.jpetstore.web.spring.AddItemToCartController handleRequest
NFO: in the else part of AddItemToCartController
ar 21, 2006 11:19:18 AM org.springframework.samples.jpetstore.dao.hibernate.HibernateImplItemDao isItemInStock
NFO: In HibernateImplItemDao.isItemInStock(String itemId):::::::::::::
ar 21, 2006 11:19:18 AM org.springframework.web.servlet.FrameworkServlet serviceWrapper
EVERE: Could not complete request
rg.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: jpetstore.hibernate.Lineitem; nested exception is org.hibernate.MappingException: Unknown entity: jpetstore.hibernate.Lineitem
rg.hibernate.MappingException: Unknown entity: jpetstore.hibernate.Lineitem
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:62)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596)
at org.springframework.orm.hibernate3.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:425)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:414)
at org.springframework.samples.jpetstore.dao.hibernate.HibernateImplItemDao.isItemInStock(HibernateImplItemDao.java:74)
at org.springframework.samples.jpetstore.domain.logic.PetStoreImpl.isItemInStock(PetStoreImpl.java:161)
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.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:163)
at $Proxy1.isItemInStock(Unknown Source)
at org.springframework.samples.jpetstore.web.spring.AddItemToCartController.handleRequest(AddItemToCartController.java:47)
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)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Name and version of the database you are using:
mysql 4.0
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
My Dao code is as folows
public boolean isItemInStock(String itemId) throws DataAccessException {
logger.info("In HibernateImplItemDao.isItemInStock(String itemId):::::::::::::");
Lineitem lineitem =(Lineitem)getHibernateTemplate().load(Lineitem.class, itemId);
int i=lineitem.getQuantity();
logger.info("i ::::::::::::"+i);
return ( i > 0);
}
So I am getting error when
Lineitem lineitem =(Lineitem)getHibernateTemplate().load(Lineitem.class, itemId);
this code of the dao is called.
Can any body help me out why this error I am getting ?
Regards,
Avinash