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

异常信息:

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>
WPS制作甘特图实操(带图超详细) 一、数据准备 图1 二、添加公式 在表格的E3处添加公式:=IF(C3>=G3,0,IF(C3+D3>=G3,G3-C3,D3)),点击该单元格的右下角。使鼠标箭头变“+”后下拉拖拽,复制该公式。F3处的公式为:=D3-E3,使用相同的拖拽方式复制公式应用,操作完毕如下图3. 图2 图3 三、插入图表 1、选中方框1内容,按住ctrl按键,继续选择2、3列的内容,点击插入全部图表中的条形图,选择2对应的图标样式,生成图6的样式。 点击图6中的3标尺,右击选择数据弹出图8,点击+号选择表格中 阅读详情

相关推荐

树莓派部署Home Assistant:打造本地化智能家居大脑

家庭自动化旨在通过技术提升居住便利性与舒适度,其核心在于中枢控制系统对各类设备的统一调度。传统云端方案虽部署简便,但存在隐私泄露、网络依赖与生态壁垒等固有缺陷。本地化部署通过将控制逻辑与数据存储于家庭内部网络,从根本上解决了这些问题,实现了数据自主、离线可用与跨品牌联动。Home Assistant作为领先的开源家庭自动化平台,结合树莓派这一低功耗、高性价比的硬件载体,为构建私有、可靠的智能家居中枢提供了成熟方案。本文以树莓派4B为例,详细阐述了从系统安装、设备集成到自动化场景创建的完整实践流程,并深入探讨

weixin_33501543的博客 373

LEFT JOIN在Java开发中的高效应用与优化实践

SQL表连接操作是数据库查询优化的核心环节,其中LEFT JOIN通过保证左表数据完整性的特性,成为业务系统开发中的关键工具。其工作原理是以左表为驱动表,当右表无匹配记录时自动填充NULL值,这种机制完美解决了历史数据关联查询中的信息丢失问题。在Java后端开发中,结合MyBatis、JPA等ORM框架,LEFT JOIN广泛应用于用户-订单关联、多级嵌套查询等典型业务场景。通过合理的索引设计(如在右表连接字段建立索引)和分页优化(使用子查询先分页),能有效提升查询性能。对于报表统计、NOT EXISTS查

cuibinmo3519的博客 403

unet学习笔记(milesial/Pytorch-UNet)

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 unet学习笔记(milesial/Pytorch-UNet)原理讲解unet_parts.py内容predict.py内容 所用到的代码Pytorch-UNet/predict.py at master · milesial/Pytorch-UNet ·GitHub 原理讲解 蓝/白色框表示 feature map; 蓝色箭头表示 3x3 卷积,用于特征提取; 灰色箭头表示skip-connection,用于特征融合; 红色箭头.

weixin_67138138的博客 2553

Hibernate-没有外键关联的两个表做联合查询

有两个表Zsplcxxb(流程表)和Lcsplsb(流程审批历史表),两个表都有lcbh(流程编号),但是没有设置外键关联,做以下的查询: from Zsplcxxb as a inner join Lcsplsb as b on a.lczbh = b.lczbh and b.blrbh='' and b.blrbh != a.sqrbh and a.clrbh != '' order by

鲲鹏宇飞(RocFly) 1万+

解决Unity与3DMax模型单位与中心点偏差的完整指南

本文详细解析了Unity与3DMax模型导入时常见的单位与中心点偏差问题,提供了从3DMax单位设置、FBX导出到Unity接收调整的完整解决方案。通过实战案例和高效工作流建议,帮助开发者实现unity与3dmax的单位统一,避免尺寸错误和轴心偏移,提升3D资源导入效率。

weixin_29015899的博客 286

【华为OD机试真题】6、数组去重和排序 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS)

题目描述 >给定一个乱序的数组,删除所有的重复元素,使得每个元素只出现一次,并且按照出现的次数从高到低进行排序,相同出现次数按照第一次出现顺序进行先后排序

KJ.JK 3887

outer or full join must be followed by path expression

我只做了两个表的简单的ID的关联 sql 如下  select media.mediaName,media.mediaId from Media media join MediaIcp mc on  media.mediaId=mc.mediaId  where mc.mediaChannelid=1 结果报错 如下: outer or full join must be followed by ...

飞鹰 821

第一节:Vben Admin 最新 v5.0 (vben5) + Python Flask 快速入门

vben5 快速入门。 Vben Admin 框架新出的版本V5.5.4,而之前的Vben Admin 2.x 目前已存档,仅进行重大问题修复。之前在2.x版本曾经简单完成了一版专栏文章,当时也是收获了一些好评和建议。本次决定在v5 版本基础上再完成一次前后端的搭建。希望大家继续多多支持。项目精简后,再次启动项目,执行 pnpm run dev点击登录,可以看到接口报错,现在前端请求的后端有报错,下一节处理这部分逻辑。

cuiwin的专栏 7065

inner/outer join in hibernate

hibernate目前(3.0) 只支持theta-style的外连接,标准的ANSI-style外连接暂不支持ANSI-style的外连接是什么样子?select template from CoTemplate  template left outer join CoTempField field  on template=field.comp_id.coTemplatewhere 

而今迈步从头跃... 6774

华为云物联网系统开发(纯云端)外包方案及项目需求说明书

提供一个详细的需求文档(SRS,Software Requirements Specification),用于指导完全零基础的非专业负责人外包兼职专业技术人员开发一款基于华为云物联网平台、Astro低代码平台和Astro Canvas大屏设计的物联网系统,纯软件实现并支持下载部署。文档涵盖详细的软硬件组成清单(聚焦软件和云服务)、技术文档要求等,确保非专业人员在移交后能够复用、扩展和操作该系统。本文档简洁、全面,适合非技术背景的管理者使用,并基于华为云生态的内部实施部署。

hy行者勇哥的博客 618

Halcon那些事:Halcon缺陷检测检测印刷数字完整性

创建模板 create_shape_model模板匹配 find_shape_model。

十多年IT经验,专注机器视觉,智能制造半导体行业 764

[Hibernate 的left join]Path expected for join!错误

使用条件如下:a left join ba must be b's parent 转载于:https://www.cnblogs.com/timelyxyz/archive/2012/07/24/2549672.html

weixin_30733003的博客 174

芒果YOLOv5改进05:损失函数IoU 篇之Repulsion Loss:原创改进损失函数 Repulsion:解决目标遮挡场景下检测,为解决密集人群检测中遮挡设计的损失函数,打造高效检测器涨点

YOLOv5改进代码实践|结合Repulsion 解决目标遮挡场景下检测🚀

包括YOLOv5、YOLOv7、YOLOv8等模型改进 4565

java hql left join_hibernate left join报错(急!在线等)

我的在mysql里正确执行的语句,转到hibernate里就报错,反正用了left join 就报错:selectd.diary_id,d.user_id,d.content,u.nick_name,count(r.re_id)from user_info u,diary dleft joindiary_comment ronr.diary_id = d.diary_idwhered.user_i...

weixin_32809369的博客 441

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

hibernate join left join hql 用法及替代方案

1、hibernate 中 left join 在hql  用之前,比如 A left join B必须关联为 a对象有b对象的应用,且在a.hbm,xml文件中有对b的配置.否则会报nullPointerException等错误   2、a left join b    没有on 关键字, sql 翻译自动为关联a.xxx left out join b.id      想a left j...

iteye_6988的博客 1576

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

hibernate left join

今天碰到一个外联结问题,总结解决的步骤: 1. 以前没注意left join on 问题,第一次使用的hql:  table a left join table b on a.id = b.aid 出现异常,经过查询,发现hibernate 不能这样使用 做链接;         2.  table a left join table b where a.id = b.aid 还有有问题,继续

flj924的专栏 1万+

java hql left join_hibernate中oracle使用原生sql查询left join

sb.append(" left join T_HOUSE_SITE_AUDITO t2 on m.F_APPLY_ID = t2.F_APPLY_ID");增加上面的语句后就报错:2015-2-2 18:32:34 org.hibernate.type.NullableType nullSafeGet信息: could not read column value from result set:...

weixin_39660408的博客 285

Springmvc RESTful和SQL LEFT JOIN知识盲点总结

写在这篇小结前的题外话:特别感谢 沉默王二 那特别能让人产生亲切感的博客,让我明白一个最普通不过的程序员都能活出不一样的自己,改变自己。同时也建议大家能抽空去看看他的博客,真的特别真实,不为别的,只让自己有迈出第一步的勇气,再次感谢! 公司最近在重构系统,作为刚进公司不久的代码小白来说是一次很重要经验积累的机会,为了能多了解一些以前不知道的知识点,厚颜无耻的缠着我的技术导师问了很多白痴的问题,现在回

xubingchuan_blog的博客 1081

hql的left join问题

1.如果HQL使用left join或其它,必须在实体类中维护对方的一个实例或集合。hql里面不能写on ,所以得on里面的条件都写在where里面。 语法如下:session.enableFilter("typefilter").setParameter("type","xxxxxxxx");    List   list=session.createQuery("select   p

fygkchina的专栏 3504

hibernate left join fetch 出错的问题

1.首先说说manyToOne的问题 比如一个用户所在的组织机构,可能是多个,最多是四个,然后userEntity有下的代码: 关联查询: 第一种方式:代码如下 StringBuilder sql = new StringBuilder(); sql.append("select a.zdbh as zdbh, a.username as username, a.x...

weixin_30617797的博客 302

Spring Data Jpa 关于fetch join 的错误

spring data jpa 文档的官方网站: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/ 在开发中使用到 Jpa Dao 方法时,出现如下错误: fetch join... but the owner of the fetched association was not presen

u013276512的博客 3058

Path expected for join!错误处理

在Hibernate中,进行连接查询时,如果使用join语句,就容易产生标题所示的错误。 比如from Content o left join Mcp mcp where o.mcp.id=mcp.id and mcp.id=2 正确的做法应该是在A中建立private Mc

KEN的专栏 5万+

org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the sel

错误日志:2009-8-20 12:17:56 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1108严重: >>java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join fetching, but the owner of th

JAVA 1万+

关于hql的inner join 查询

先表达一下找了一个下午到现在还木有吃饭的感觉, 第一、我怎么这么笨 第二、我果然还是个菜鸟 正题: 三张表 UserSpecSer Service 以及Parameter String hql="select uss from UserSpecSer uss inner join fetch uss.service s inner join fetch s.parameters wher...

cindyliao的博客 2419

Path expected for join!的解决办法

Path expected for join! [SELECT count(*) FROM cn.com.jsoft.entities.TDSysnphoto p left join TDSysnotice s where p.snid = s.id]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: Path e...

weixin_34161064的博客 1287
上一篇: 使用google的API进行搜索
下一篇: hibernate链接mysql数据库异常处理
future_hui
博客等级 码龄20年 0粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值