-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Parent / Child relationship for single table objects
PostPosted: Wed May 18, 2005 3:59 pm 
Newbie

Joined: Wed Dec 29, 2004 2:37 am
Posts: 11
I am writing an application that works with Inventory. After adding the set as defined below, hibernate throws an initialization exception. I am using hibernate 3.0.3 on postgresql 8, though my real problem i fear lies in the fact that I just dont seem to be able to understand collections in hibernate.

JAVA and Xml included below

table design

Table Parts
part_id [ Primary Key ]

Table Assembly_Parts
Assembly_Part_Id [ Primary Key ]
Kit_id [ Link to Parts table ]
Part_id [ Link to Parts table ]
Qty_Of_Part [ float ]

java classes

Part.java
int id = 0;
Set assembly_parts = new HashSet();

AssemblyPart.java
Part kit_id = new Part();
Part part_id = new Part();
float qty_of_part = 0;

In my Part XML, I am trying to create a set of assembly parts using a set as follows [ the comments are not in the real xml file ]

<class name="Part">

<set name="assembly_parts"> // i think this is supposed to be the name of the collection on the parent?
<key column="kit_id" /> // From best I can understand, the key refers to the kit_id field in the Assembly_Parts table
<one-to-many class="AssemblyPart" />
</set>
</class>

After adding this to my hibernate.hbm.xml file, It will no longer work. I have narrowed it down to the <set> tag, because the entire application works perfectly if I remove it. Can someone point out where I am blantantly wrong on the design of this file?

I can provide more if needed, but as i believe the problem is completely my comprehension, hopefully this will be enough.

Thanks,


Top
 Profile  
 
 Post subject: Re: Parent / Child relationship for single table objects
PostPosted: Wed May 18, 2005 4:11 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
cgamble wrote:
I am writing an application that works with Inventory. After adding the set as defined below, hibernate throws an initialization exception. I am using hibernate 3.0.3 on postgresql 8, though my real problem i fear lies in the fact that I just dont seem to be able to understand collections in hibernate.

JAVA and Xml included below

table design

Table Parts
part_id [ Primary Key ]

Table Assembly_Parts
Assembly_Part_Id [ Primary Key ]
Kit_id [ Link to Parts table ]
Part_id [ Link to Parts table ]
Qty_Of_Part [ float ]

java classes

Part.java
int id = 0;
Set assembly_parts = new HashSet();

AssemblyPart.java
Part kit_id = new Part();
Part part_id = new Part();
float qty_of_part = 0;

In my Part XML, I am trying to create a set of assembly parts using a set as follows [ the comments are not in the real xml file ]

<class name="Part">

<set name="assembly_parts"> // i think this is supposed to be the name of the collection on the parent?
<key column="kit_id" /> // From best I can understand, the key refers to the kit_id field in the Assembly_Parts table
<one-to-many class="AssemblyPart" />
</set>
</class>

After adding this to my hibernate.hbm.xml file, It will no longer work. I have narrowed it down to the <set> tag, because the entire application works perfectly if I remove it. Can someone point out where I am blantantly wrong on the design of this file?

I can provide more if needed, but as i believe the problem is completely my comprehension, hopefully this will be enough.

Thanks,


Should be <key column="part_id"> since this is what tells Hibernate the how the AssemblyPart is related to the Part.

I would need to see your code and the stack trace to provide any meaningful information beyond this.


Top
 Profile  
 
 Post subject: My Stack Trace
PostPosted: Thu May 19, 2005 9:36 pm 
Newbie

Joined: Wed Dec 29, 2004 2:37 am
Posts: 11
INFO: Mapping resource: com/hbm/PageSecurity.hbm.xml
May 19, 2005 8:33:29 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.dps.PageSecurity -> tsyssecurity
May 19, 2005 8:33:29 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
May 19, 2005 8:33:29 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
May 19, 2005 8:33:29 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
May 19, 2005 8:33:29 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.dps.Quote.lineitems -> tdatquotelineitem
MonitorFilter::ServletException
MonitorFilter::A web application object caused an exception
MonitorFilter::javax.servlet.ServletException: Filter execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:305)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)


Top
 Profile  
 
 Post subject: PLEASE CLOSE
PostPosted: Thu May 19, 2005 11:51 pm 
Newbie

Joined: Wed Dec 29, 2004 2:37 am
Posts: 11
The solution was that the hbm file was not in the same directory as the class, and I did not specify the full class.

Thanks for your thoughts


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.