锁定老帖子 主题:父子关系及inverse 详解
该帖已经被评为精华帖
|
|
---|---|
作者 | 正文 |
发表时间:2004-04-15
为什么谈得是inverse=true,但是从头到尾都没有在代码里出现,只说不写会怎么样,反而贴上了代码。
这是我第二次读,一时冲动把自己的所有在one-to-many里的inverse=true删掉了,改在many-to-one里。 现在是两个小时以后,我把他们又改回来了,原来我以前看reference的时候的理解是正确的。 我看让人误解的文章不是什么好文章。 |
|
返回顶楼 | |
发表时间:2004-04-15
inverse="true"就相当于是RDBMS当中的PK-->FK的关系,本来PK不用关心FK的指向就是了,inverse="true"就是反映了这种关系.
|
|
返回顶楼 | |
发表时间:2004-04-21
只设置了一个父亲,没有保存儿子,
在查询时, Query qry = session.createQuery( "from Service as obj"); List list =qry.list(); 报HIBERNATE异常 net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.oss.entity.OneOffService.setScplans at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:216) at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2137) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:239) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132) at net.sf.hibernate.loader.Loader.doList(Loader.java:949) at net.sf.hibernate.loader.Loader.list(Loader.java:940) at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:833) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1475) at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39) at com.oss.action.ServiceAction.performList(ServiceAction.java:128) at com.oss.action.ServiceAction.executeAction(ServiceAction.java:73) at com.oss.action.BaseAction.execute(BaseAction.java:66) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619) at java.lang.Thread.run(Thread.java:534) Caused by: net.sf.cglib.beans.BulkBeanException at com.oss.entity.OneOffService$$BulkBeanByCGLIB$$77e38f5e.setPropertyValues(<generated>) at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:211) ... 46 more |
|
返回顶楼 | |
发表时间:2004-04-22
已经解决了!!配置问题
|
|
返回顶楼 | |
发表时间:2004-04-23
才学这个东东,对我很有帮助的
|
|
返回顶楼 | |
发表时间:2004-04-27
很不错,我一直想弄明白inverse到底起什么作用呢,这回知道了。
|
|
返回顶楼 | |
发表时间:2004-06-10
谢谢楼主~~
学习中…… |
|
返回顶楼 | |
发表时间:2004-06-11
请问,如果删除Parent,Child会被对应删除吗?~
这时inverse设置有什么影响么?~ 谢谢! |
|
返回顶楼 | |
发表时间:2004-07-05
好文章,只是楼主有些地主说有不太明白!
如果把三种情况的配置文件,运行文件,和运行结果分别讨论就太好啦 |
|
返回顶楼 | |
发表时间:2004-08-14
在父子关系中,如果存在赃数据,楼主怎么解决的呢?
还是说压根就不考虑赃数据的问题的? |
|
返回顶楼 | |