- 浏览: 38473 次
- 性别:
- 来自: 四川
文章分类
最新评论
-
ottoliu:
相当有道理,不晓得我们在技术上可以走多远
读博体会 -
ottoliu:
技术流派一定要到氛围好的地方 加油!
关于工作 -
ottoliu:
现在还有点看不懂 稍后再好好看看
Criteria 的完整用法 -
ottoliu:
^[0-9]+\.{0,1}[0-9]{0,2}$
这个只能两 ...
关于正则表达式 -
猪圈羊圈:
沙发都没有一个!
伤心了!
Hibernate查询 2级以上外键关联查询的问题
对象关系
ReceiptUnqualifiedRecord --poDetail--Po--Company
详细关系如下:
现在有ReceiptUnqualifiedRecordManager发起查询 查询条件问Po对应的Company对象的code
springside页面代码
点击查询 报如下错误
报如上错误之前,filtermap已经是封装成功的
如下:
求助高人
ReceiptUnqualifiedRecord --poDetail--Po--Company
详细关系如下:
ReceiptUnqualifiedRecord 中 /** * 订单明细 * * @hibernate.many-to-one * class="com.changhong.pcs.domain.PoDetail" * @struts.dynaform-field * @return */ public PoDetail getPoDetail() { return poDetail; } public void setPoDetail(PoDetail poDetail) { this.poDetail = poDetail; } PoDetail 中 /** * 订单 * * @hibernate.many-to-one column="PoCode" * class="com.changhong.pcs.domain.Po" * property-ref="pocode" * @struts.dynaform-field * @return */ public Po getPo() { return po; } public void setPo(Po po) { this.po = po; } Po中 /** * 公司 * * @hibernate.many-to-one column="CompanyCode" * class="com.changhong.fw.module.domain.Company" * property-ref="code" * @struts.dynaform-field * @return */ public Company getCompany() { return company; } public void setCompany(Company company) { this.company = company; } Company中的code属性就是String
现在有ReceiptUnqualifiedRecordManager发起查询 查询条件问Po对应的Company对象的code
springside页面代码
<select name="search_poDetail_po_company_code"> <option value=""><fmt:message key="prompt.all" /></option> <c:forEach var="company" items="${companies}"> <option value="${company.code}">${company.descn}</option> </c:forEach> </select>
点击查询 报如下错误
严重: Servlet.service() for servlet action threw exception org.hibernate.QueryException: could not resolve property: po.company.code of: com.changhong.pcs.domain.PoDetail at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43) at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:63) at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31) at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1302) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:434) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:394) at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:45) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:334) at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:71) at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:68) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305) at com.changhong.fw.core.commons.support.page.CriteriaPage.getPageInstanceByCount(CriteriaPage.java:69) at com.changhong.fw.core.commons.support.page.CriteriaPage.getPageInstance(CriteriaPage.java:42) at com.changhong.fw.core.commons.base.dao.BaseHibernateDao.pagedQuery(BaseHibernateDao.java:316) at com.changhong.fw.core.commons.base.dao.BaseHibernateDao.pagedQuery(BaseHibernateDao.java:309) at com.changhong.fw.core.commons.base.dao.BaseHibernateDao.findBy(BaseHibernateDao.java:267) at com.changhong.fw.core.commons.base.service.BaseSpringManager.search(BaseSpringManager.java:210) at com.changhong.fw.core.commons.base.service.BaseSpringManager$$FastClassByCGLIB$$d8387cf7.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:714) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:66) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:652) at com.changhong.pcs.service.imp.ReceiptUnqualifiedRecordManagerImp$$EnhancerByCGLIB$$9c624680.search(<generated>) at com.changhong.fw.core.commons.base.web.StrutsEntityAction.commonOperationForList(StrutsEntityAction.java:575) at com.changhong.fw.core.commons.base.web.StrutsEntityAction.list(StrutsEntityAction.java:528) at com.changhong.fw.core.commons.base.web.StrutsEntityAction.unspecified(StrutsEntityAction.java:493) at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:249) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.opensymphony.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:56) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.changhong.fw.core.web.filter.ServletPathFilter.doFilter(ServletPathFilter.java:30) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.changhong.fw.core.web.filter.MessageFilter.doFilter(MessageFilter.java:30) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.changhong.fw.core.web.filter.BackQueryUrlFilter.doFilter(BackQueryUrlFilter.java:47) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.extremecomponents.table.filter.AbstractExportFilter.doFilter(AbstractExportFilter.java:49) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.changhong.fw.security.web.filter.LoginFilter.doFilter(LoginFilter.java:62) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.switchuser.SwitchUserProcessingFilter.doFilter(SwitchUserProcessingFilter.java:341) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:175) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:229) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:106) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:229) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.captcha.CaptchaValidationProcessingFilter.doFilter(CaptchaValidationProcessingFilter.java:110) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:286) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149) at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119) at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55) at org.extremecomponents.table.filter.SitemeshPageFilter.doFilter(SitemeshPageFilter.java:39) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.changhong.fw.core.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:76) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619)
报如上错误之前,filtermap已经是封装成功的
如下:
filterMap is {poDetail_po_company_code=QueryData[cp=like:tp=string:value=3000]} criteria is CriteriaImpl(com.changhong.pcs.domain.ReceiptUnqualifiedRecord:this[Subcriteria(poDetail:poDetail)][deleteFlag=0, poDetail.po.company.code like %3000%])
求助高人
相关推荐
总结,通过上述步骤,我们可以使用Hibernate的`@OneToOne`注解实现一对一唯一外键关联映射,并实现双向关联。在实际项目中,应根据业务需求选择合适的级联操作和关联维护方式,以确保数据的完整性和一致性。
在Java的持久化框架Hibernate中,一对一(One-to-One)关联映射是常见的...以上就是关于Hibernate一对一唯一外键关联映射(单向关联)的详细说明。通过这种方式,我们可以轻松地在Java应用中处理数据库的一对一关系。
总结,Hibernate的一对一唯一外键关联映射主要涉及映射配置、Java代码、数据库设计以及对象的操作和查询。在实际开发中,我们需要根据业务需求选择合适的关联方式,并关注性能和数据完整性的优化。
本篇将详细讲解如何使用Hibernate进行一对一单向外键关联,并且该关联涉及到联合主键的注解配置。 首先,一对一关联可以分为两种类型:单向和双向。在单向一对一关联中,只有一个实体知道另一个实体的存在,而另一...
本篇将深入探讨Hibernate中的一对一唯一外键关联映射,特别是双向关联的实现。 ### 1. 一对一关联概述 一对一关联意味着一个实体只能与另一个实体的单一实例相关联,这种关系通常出现在两个表之间,其中一个表的...
2. **唯一外键关联** - 在一对一关联中,唯一外键关联是指在一个实体中定义了另一个实体的主键作为其字段,形成外键约束,确保了数据的一致性和完整性。 3. **双向关联与单向关联** - **单向关联**:只有一方...
Hibernate 一对一唯一外键关联映射详解 Hibernate是一种流行的Java持久层框架,提供了多种关联映射方式,其中一对一唯一外键关联映射是一种常见的关联方式。在本文中,我们将详细介绍Hibernate一对一唯一外键关联...
以上就是关于Hibernate中一对一单向外键关联的基本介绍。通过理解和熟练掌握这种关联方式,开发者可以更高效地设计和管理数据库模型,提升应用性能。在实际项目中,还需结合业务场景灵活运用,并注意性能优化。通过...
本篇将深入探讨Hibernate中的一对一单向外键关联,通过注解和XML配置两种方式进行实现。这种关联允许一个实体类与另一个实体类之间存在一对一的关系,并且只在其中一个实体类中维护这种关系。 首先,我们来理解一对...
2. 唯一外键关联保持了数据独立性,避免冗余,但增加了表的复杂度,需要额外的外键字段。 四、源码分析: 在Hibernate源码中,`OneToOne`和`PrimaryKeyJoinColumn`等注解会由元数据解析器处理,生成对应的SQL JOIN...
在Java的持久化框架Hibernate中,一对一双向外键关联是一种常见的关系映射方式,用于表示两个实体类之间一对一的关联关系。在这个场景下,每个实体都有一个引用指向另一个实体,形成双向关联。本篇文章将深入探讨...
**标题详解:**“Hibernate ORM - 一对一外键关联关系” 在Java开发中,Hibernate是一个非常流行的ORM(对象关系映射)框架,它允许开发者用面向对象的方式处理数据库操作,从而减少与SQL的直接交互。"一对一(One-...
在Java持久化框架Hibernate中,一对多外键单向关联是一种常见的关系映射方式,它描述了一对多的关系,其中一个实体(例如Person)可以与多个其他实体(例如Address)相关联,而关联的方向只从多方(Address)指向...
首先,一对一外键关联指的是一个实体通过外键直接引用另一个实体的主键。在单向关联中,只有其中一个实体知道另一个实体的存在,而另一个实体则无感知。这种关联通常体现在数据库设计中,比如一个用户只有一个账户,...
总的来说,Hibernate的一对一唯一外键关联(单向关联)是通过在一方实体中定义另一方实体的引用,并通过注解或XML映射文件进行配置来实现的。这种关联方式简化了对象关系的管理,但同时也需要开发者在操作关联对象时...
在本教程中,我们将深入探讨Hibernate中的一个关键概念——关系映射,特别是“一对一”双向外键关联。这种关联类型在数据库设计中很常见,尤其是在处理具有紧密耦合的实体时。Hibernate作为Java中广泛使用的对象关系...