Joined: Mon Aug 22, 2005 3:34 am Posts: 7
|
Hi,
i m trying to use inner join in hql but an exception is occuring
does anyone know the reason then plz help me
Hibernate version:3.0
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 package = "com.ts.hibernateBean">
<class name="ItemBean" table="ITEM">
<id name="itemId" unsaved-value="null" > <column name="ITEM_ID" not-null="true"/> <generator class="identity"/> </id> <property name="itemName"> <column name="ITEM_NAME"/> </property> <property name="itemDescription"> <column name="ITEM_DESCRIPTION"/> </property> </class>
<class name="CustomerBean" table="CUSTOMER" lazy="true"> <id name="customerId" unsaved-value="null" > <column name="CUSTOMER_ID" not-null="true"/> <generator class="identity"/> </id> <property name="customerName"> <column name="CUSTOMER_NAME" not-null="true"/> </property> </class>
<class name="OrderBean" table="ORDERINFO" lazy="true"> <id name="orderId" unsaved-value="null" > <column name="ORDER_ID" not-null="true"/> </id> <property name="dateField"> <column name="ORDER_DATE"/> </property> <property name="intAmount"> <column name="TOTAL_AMOUNT" not-null="true"/> </property> <property name="intCustomerId"> <column name="CUSTOMER_ID" not-null="true"/> </property>
<many-to-one name="customer" column="CUSTOMER_ID" unique="true" not-null="true" insert="false" update="false" class="CustomerBean"/>
<set name="items" table="ORDER_ITEM" lazy="true"> <!--batch-size="10"--> <key column="ORDER_ID"/> <many-to-many column="ITEM_ID" unique="true" class="ItemBean"/> </set> <!--join table="ORDER_ITEM"> <key column="ORDER_ID"/> <property name="intItemId" column="ITEM_ID" /> <property name="intQuantity" column="QUANTITY" /> </join--> </class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Query query2 = session.createQuery("from OrderBean order inner join fetch com.ts.hibernateBean.ItemBean item"); try{ List list2 = query2.list(); }catch(Exception e){ System.out.println("Item Exception Occurred : "); e.printStackTrace(); }
Full stack trace of any exception that occurs: Item Exception Occurred : java.lang.NullPointerException at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker .java:264) at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker .java:3022) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker .java:2841) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWa lker.java:2719) at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker. java:513) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java: 371) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWa lker.java:201) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.j ava:151) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl .java:189) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorIm pl.java:130) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl .java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.jav a:427) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74) at com.ts.hibernateAction.HibernateAction.viewAllOrders(HibernateAction. java:190) at com.ts.hibernateAction.HibernateAction.execute(HibernateAction.java:5 5) at org.apache.struts.action.RequestProcessor.processActionPerform(Reques tProcessor.java:465) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja va:274) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:142 2) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:284) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:204) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:257) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:564) at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard ContextValve.java:245) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:199) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:564) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:195) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:151) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:164) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:149) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:564) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:156) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv eContext.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:564) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20 6) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :828) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ssConnection(Http11Protocol.java:700) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java :584) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:683) at java.lang.Thread.run(Thread.java:536)
Name and version of the database you are using: SQL Server 2000
|
|