异常信息:
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>
分享到:
相关推荐
对于多表连接,Criteria API 可以通过 JoinType 类型的 JOIN 方法实现,如 INNER JOIN、LEFT JOIN 等。 **分页查询** 在大数据量的场景下,分页查询是必不可少的,它可以提高用户体验并减少服务器负载。Hibernate ...
Hibernate支持多种连接类型,包括`inner join`(内连接)、`left outer join`(左外连接)、`right outer join`(右外连接)和`full join`(全连接)。`with`关键字用于提供额外的连接条件,类似于SQL中的`on`关键字...
HQL(Hibernate Query Language)是 Hibernate 中的一种强大的查询语言,它看起来很像 SQL,但是不要被语法结构上的相似所迷惑,HQL 是非常有意识的被设计为完全面向对象的查询,它可以理解如继承、多态和关联之类的...
- 支持多种连接类型,包括 `inner join`(内连接)、`left outer join`(左外连接)、`right outer join`(右外连接)和 `full join`(全连接)。其中,`full join` 不太常用。 - `join` 关键字还可以简写,例如 `...
- **左外连接**:`left outer join`允许在左侧实体未找到匹配项时返回null值,例如`left outer join cat.kittens as kitten`。 - **右外连接**:`right outer join`与左外连接相反,如果右侧实体未找到匹配项,则...
首先,让我们来看看“增”操作。在Hibernate中,可以通过Session对象的save()或saveOrUpdate()方法来保存一个新的对象到数据库。例如,创建一个新的Programmer对象并保存: ```java SessionFactory sessionFactory ...
- 示例:`from Cat as cat join cat.mate as mate left join cat.kittens as kitten`。 - **fetch连接**:用于在一次查询中同时初始化相关联的对象或集合。 - 示例:`from Cat as cat join fetch cat.mate left ...
1. **外连接**:分为左连接(LEFT JOIN)和右连接(RIGHT JOIN),在没有查询条件时,能获取所有信息,左边或右边表的所有记录都会被包含。当有查询条件时,只保留符合条件的关联记录。 2. **内连接**(INNER JOIN...
2. 外连接(Outer Join):分为左外连接(Left Outer Join)、右外连接(Right Outer Join)和全外连接(Full Outer Join)。外连接会返回所有匹配和不匹配的记录,不匹配的记录用NULL填充。左外连接返回左表的所有...
- “fulljoin”、“leftjoin”、“rightjoin”是SQL中的联结类型,用于数据库中表的查询操作。 - “excel”、“word”、“CVS”指的是电子表格、文档处理和逗号分隔值文件,这些可能是实习工作中涉及到的文件处理...
SELECT * FROM bloc b LEFT JOIN company c ON b.company_id = c.id WHERE b.id = #{id} ``` 在这个查询中,我们使用了LEFT JOIN来获取区块及其关联的公司信息。`#{id}`是MyBatis的参数占位符,用于传入区块ID...