hibernate报错unexpected token: mo near lin

问题描述

运行了半天报这个错误Exceptioninthread"main"org.springframework.orm.hibernate3.HibernateQueryException:unexpectedtoken:monearline1,column309[selectbrandfromcn.webstudio.bean.McurwDataCampaignBrandasbrandINNERJOINbrand.mcurwDataTeamasteamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModelsbamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModels.mcurwDataModelasmowhere1=1andteam.teamName=?andbrand.campaignEndTime>=?mo.amodelName=?andbrand.campaignStartTime<=?];nestedexceptionisorg.hibernate.hql.ast.QuerySyntaxException:unexpectedtoken:monearline1,column309[selectbrandfromcn.webstudio.bean.McurwDataCampaignBrandasbrandINNERJOINbrand.mcurwDataTeamasteamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModelsbamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModels.mcurwDataModelasmowhere1=1andteam.teamName=?andbrand.campaignEndTime>=?mo.amodelName=?andbrand.campaignStartTime<=?]atorg.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)atorg.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)atorg.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)atorg.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)atorg.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)atcn.webstudio.dao.impl.McurwDataCampaignBrandDaoImpl.findByPropertys(McurwDataCampaignBrandDaoImpl.java:229)atcn.webstudio.service.impl.CampaignServiceImpl.findByCondition(CampaignServiceImpl.java:150)atTest.Test.main(Test.java:28)Causedby:org.hibernate.hql.ast.QuerySyntaxException:unexpectedtoken:monearline1,column309[selectbrandfromcn.webstudio.bean.McurwDataCampaignBrandasbrandINNERJOINbrand.mcurwDataTeamasteamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModelsbamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModels.mcurwDataModelasmowhere1=1andteam.teamName=?andbrand.campaignEndTime>=?mo.amodelName=?andbrand.campaignStartTime<=?]atorg.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)atorg.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244)atorg.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155)atorg.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)atorg.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)atorg.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)atorg.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)atorg.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)atorg.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)atorg.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)atorg.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:923)atorg.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)...5moreCausedby:line1:309:unexpectedtoken:moatorg.hibernate.hql.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:1038)atorg.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3422)atorg.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3200)atorg.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3082)atorg.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2802)atorg.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2667)atorg.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2449)atorg.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2413)atorg.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2341)atorg.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2296)atorg.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:2082)atorg.hibernate.hql.antlr.HqlBaseParser.logicalExpression(HqlBaseParser.java:1858)atorg.hibernate.hql.antlr.HqlBaseParser.whereClause(HqlBaseParser.java:454)atorg.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:708)atorg.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296)atorg.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159)atorg.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:238)...15more我这有4个表一个是车型活动表还有一个车型表一个车型表和活动表的中间表还有一个组表因为一个活动可以有多个车型我就弄了一个中间表中间表只有三个字段本表id,车型id(外键)和活动Id(外键)也就是活动表有一个主键中间表两个外键一个主键车型表一个主键还有一个组表没什么用我就不贴了活动类Xml<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><!--MappingfileautogeneratedbyMyEclipsePersistenceTools--><hibernate-mapping><classname="cn.webstudio.bean.McurwDataCampaignBrand"table="mcurw_data_campaign_brand"><idname="campaignId"type="java.lang.Integer"><columnname="campaign_id"/><generatorclass="identity"/></id><many-to-onename="mcurwDataTeam"class="cn.webstudio.bean.McurwDataTeam"fetch="select"lazy="false"><columnname="campaign_team_id"/></many-to-one><propertyname="campaignTeam"type="java.lang.Integer"><columnname="campaign_team"not-null="true"><comment>活动归属组的ID</comment></column></property><propertyname="campaignStartTime"type="java.lang.Long"><columnname="campaign_start_time"not-null="true"><comment>活动开始时间</comment></column></property><propertyname="campaignEndTime"type="java.lang.Long"><columnname="campaign_end_time"not-null="true"><comment>活动结束时间</comment></column></property><setname="mcurwRelationshipCampaignBrandAndModels"inverse="true"><key><columnname="brand_id"not-null="true"><comment>活动ID</comment></column></key><one-to-manyclass="cn.webstudio.bean.McurwRelationshipCampaignBrandAndModel"/></set></class></hibernate-mapping>

中间表xml<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><!--MappingfileautogeneratedbyMyEclipsePersistenceTools--><hibernate-mapping><classname="cn.webstudio.bean.McurwRelationshipCampaignBrandAndModel"table="mcurw_relationship_campaign_brand_and_model"><idname="campaignId"type="java.lang.Integer"><columnname="campaign_id"/><generatorclass="identity"/></id><many-to-onename="mcurwDataCampaignBrand"class="cn.webstudio.bean.McurwDataCampaignBrand"fetch="select"lazy="false"><columnname="brand_id"not-null="true"><comment>活动ID</comment></column></many-to-one><many-to-onename="mcurwDataModel"class="cn.webstudio.bean.McurwDataModel"fetch="select"lazy="false"><columnname="model_id"not-null="true"><comment>车型ID</comment></column></many-to-one></class></hibernate-mapping>

车型xml<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><!--MappingfileautogeneratedbyMyEclipsePersistenceTools--><hibernate-mapping><classname="cn.webstudio.bean.McurwDataModel"table="mcurw_data_model"><idname="modelId"type="java.lang.Integer"><columnname="model_id"/><generatorclass="identity"/></id><propertyname="modelName"type="java.lang.String"><columnname="model_name"not-null="true"/></property><setname="mcurwRelationshipCampaignBrandAndModels"inverse="true"lazy="false"><key><columnname="model_id"not-null="true"><comment>车型ID</comment></column></key><one-to-manyclass="cn.webstudio.bean.McurwRelationshipCampaignBrandAndModel"/></set><setname="mcurwDataCampaignProducts"inverse="true"lazy="false"><key><columnname="campaign_model_id"not-null="true"><comment>车型ID</comment></column></key><one-to-manyclass="cn.webstudio.bean.McurwDataCampaignProduct"/></set></class></hibernate-mapping>

我拼写了hql语句是这样的selectbrandfromMcurwDataCampaignBrandasbrandINNERJOINbrand.mcurwDataTeamasteamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModelsbamINNERJOINbrand.mcurwRelationshipCampaignBrandAndModels.mcurwDataModelasmowhere1=1andteam.teamName=?andbrand.campaignEndTime>=?mo.amodelName=?andbrand.campaignStartTime<=?请问这么写有问题么?我写了另一个跟这个差不多的是正确的,但是这个有一个跟那个不太一样.就是那个不需要中间表,这个有中间表的应该怎么操作。错误告诉我大概得意思是brand.mcurwRelationshipCampaignBrandAndModels.mcurwDataModelasmo这个mo它说是未知的请高手解答,在线等比较急

解决方案

解决方案二:
少了ON条件
解决方案三:
join是不需要no条件的吧?
解决方案四:
找到错误了
解决方案五:
他自己把on写成om了。
解决方案六:
学习了

时间: 2024-10-26 08:20:55

hibernate报错unexpected token: mo near lin的相关文章

flume hdfs-flume1.5.2希望将log4j的日志写入hdfs报错Unexpected exception from downstream.

问题描述 flume1.5.2希望将log4j的日志写入hdfs报错Unexpected exception from downstream. 1.conf文件如下 agent1.sources = source1agent1.channels = channel1agent1.sinks = snik1# sourceagent1.sources.source1.type = avroagent1.sources.source1.bind = nnodeagent1.sources.sourc

测试hibernate报错:无法加载hbm.xml映射文件

问题描述 测试hibernate报错:无法加载hbm.xml映射文件 hibernate配置文件里,也是加载了此映射文件的哦 解决方案 解决办法---------映射文件User.hbm.xml中,class标签的name属性要上全限定类名:class name="com.cailikun.domain.User" 解决方案二: http://xiaoyaocao.iteye.com/blog/1837133

Ensemble.Tofino运行报错Unexpected java bridge exception的解决

作为Visual Studio插件的Flex开发工具,Ensemble公司的Tofino确实很吸引人,包含编译环境的安装文件总共才122M,比起Flex Builder要不少.而且,对于熟悉了VS开发环境的.Net程序员,用这样的插件来做Flex开发方便了很多. 从官网下载安装文件,选择122M的包含开发编译环境的安装包下载.关闭Visual Studio,安装成功后开启Visual Studio,正常情况下Flex项目会出现在新建项目的页面上.新建一个Flex工程,如果你机器的java环境配置

hibernate报错

问题描述 数据库为:mysql,数据库表:user,主键为usercode和comcodehibernate的配置文件user.hbm.xml如下:<classname="com.oms.bean.user"table="user"catalog="omsdb"><composite-idname="id"class="com.oms.bean.OmuserId"><key-p

【hibernate 报错】No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer 【get和load的区别】

报错: 1 HTTP Status 500 - Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered 2 to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_

spring集成hibernate 报错 The application must supply JDBC connections

问题描述 Caused by: java.lang.UnsupportedOperationException: The application must supply JDBC connectionshibernate和spring的配置如图请帮我分析分析 解决方案 mysql驱动包有没有引入 ?

java hibernate运行起动报错

问题描述 java hibernate运行起动报错 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sess

mvn打包报错:Failed to load ApplicationContext

问题描述 mvn打包报错:Failed to load ApplicationContext ApplicationContext中扫描的包: /context:component-scan springmvc.xml中扫描的包: <context:component-scan base-package="com.aa.controller" /> 解决方案 问题已解决,pom配置文件中没有配置加载resources,所以加载不到resources目录下面的配置文件!加上配

processing-java 数组定义,报错:unexpected token: [ 如何解决?

问题描述 java 数组定义,报错:unexpected token: [ 如何解决? RT,代码如下: class Data { String name; int size; int level; int father; int x = 0; int y = 0; int w = 0; int h = 0; Data(String tname, int tsize, int tlevel, int tfather) { name = tname; size = tsize; level = t