论坛首页 Java企业应用论坛

Hibernate left join 错误大家帮忙看看谢谢!

浏览 3056 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2008-05-05  
异常信息:
org.springframework.orm.hibernate3.HibernateQueryException: outer or full join must be followed by path expression [select pt.productid,pt.name,pt.price,pt.content,pt.createtime,pt.hitCount, a.filepath from com.enation.groupware.product.core.Product pt left join ProductAttachment pa where pt.productid = pa.productid.productid and pa.isDefault=1 ProductAttachment pa inner join Attachment a where pa.attachmentid att att.attachmentid = a.attachmentid and pt.deleteflag=0 order by p.createtime desc]; nested exception is org.hibernate.QueryException: outer or full join must be followed by path expression [select pt.productid,pt.name,pt.price,pt.content,pt.createtime,pt.hitCount, a.filepath from com.enation.groupware.product.core.Product pt left join ProductAttachment pa where pt.productid = pa.productid.productid and pa.isDefault=1 ProductAttachment pa inner join Attachment a where pa.attachmentid att att.attachmentid = a.attachmentid and pt.deleteflag=0 order by p.createtime desc]
Caused by: org.hibernate.QueryException: outer or full join must be followed by path expression [select pt.productid,pt.name,pt.price,pt.content,pt.createtime,pt.hitCount, a.filepath from com.enation.groupware.product.core.Product pt left join ProductAttachment pa where pt.productid = pa.productid.productid and pa.isDefault=1 ProductAttachment pa inner join Attachment a where pa.attachmentid att att.attachmentid = a.attachmentid and pt.deleteflag=0 order by p.createtime desc]
	at org.hibernate.hql.classic.FromParser.token(FromParser.java:170)
	at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:86)
	at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108)
	at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28)
	at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:216)
	at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:185)
	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
	at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
	at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
	at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
	at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1202)
	at $Proxy2.createQuery(Unknown Source)
	at com.enation.framework.dao.BaseDAO$1.doInHibernate(BaseDAO.java:40)
	at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
	at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
	at com.enation.framework.dao.BaseDAO.getObjectsByPage(BaseDAO.java:36)
	at com.enation.groupware.product.core.MysqlCmsProductDAO.getProductList(MysqlCmsProductDAO.java:90)
	at com.enation.groupware.product.core.MysqlCmsProductDAO$$FastClassByCGLIB$$16d2a479.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
	at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:694)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
	at com.enation.groupware.product.core.MysqlCmsProductDAO$$EnhancerByCGLIB$$c39d56b0.getProductList(<generated>)
	at com.enation.cms.test.TestDAOTest.testList(TestDAOTest.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)




HQL:
 
String hql = "";
hql += "select pt.productid,pt.name,pt.price,pt.content,pt.createtime,pt.hitCount, a.filepath " + 
"from Product pt " + 
"left join ProductAttachment pa where pt.productid = pa.productid.productid and pa.isDefault=1 ProductAttachment pa " + "inner join Attachment a where pa.attachmentid att att.attachmentid = a.attachmentid" + " and pt.deleteflag=0"; 
</p>


*.hbl

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="com.enation.groupware.product.core.Product" table="enation_product" lazy="true">
        <id name="productid" type="java.lang.Long">
            <column name="productid" />
            <generator class="identity"></generator>
        </id>
        <many-to-one name="enationProductdetail" class="com.enation.groupware.product.core.ShopProdctDetail"  cascade="save-update"  fetch="select">
            <column name="detailid" />
        </many-to-one>
        <many-to-one name="enationProductcategory" class="com.enation.groupware.product.core.ProductCategory" fetch="select">
            <column name="categoryid" />
        </many-to-one>
              
        <property name="name" type="java.lang.String">
            <column name="name" />
        </property>
        <property name="hitCount" type="java.lang.Integer">
            <column name="hitCount" />
        </property>
        <property name="price" type="java.lang.Double">
            <column name="price" precision="12" />
        </property>
        <property name="content" type="org.springframework.orm.hibernate3.support.ClobStringType">
            <column name="content"/>
        </property>
        <property name="deleteflag" type="java.lang.Integer">
            <column name="deleteflag" />
        </property>
        <property name="createtime" type="java.util.Date">
            <column name="createtime" />
        </property>
        
         <set name="enationProductAttachment" cascade="save-update" inverse="true" lazy="true">
			<key>
				<column name="productid" />
			</key>
			<one-to-many 
				class="com.enation.groupware.product.core.ProductAttachment" />
		</set>
    </class>
</hibernate-mapping>
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics