-->
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.  [ 7 posts ] 
Author Message
 Post subject: could no create child object alone in parent-child relation
PostPosted: Thu Oct 23, 2003 7:03 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:47 pm
Posts: 21
Hi,
I have a requirement in my application to use a Parent-Child relation as described below.

Parent : Folder
Child : subFolder or Document

I need to do the following:
1. create the parent alone with out any children
2. create a child alone in an existing parent folder

I used the following relationship mapping

<!-- Folder Model definition -->
<class name="citadon.bizcomponent.dms.model.Folder" table="folder" dynamic-update="true">
<id name="ObjectId" type="string" column="FolderId" unsaved-value="null">

<generator class="assigned"/>
</id>
<set name="ChildDocuments" table="folder" inverse="true" lazy="true">
<key column="FolderId"/>
<one-to-many class="citadon.bizcomponent.dms.model.Document"/>
</set>
<!-- SubFolder to Folder Relation -->
<many-to-one name="ParentFolder" column="ParentId" class="citadon.bizcomponent.dms.model.Folder" lazy="true"/>
<!-- Folder Folder Relation -->
<set name="ChildFolders" table="folder" inverse="true" lazy="true">
<key column="ParentId"/>
<one-to-many class="citadon.bizcomponent.dms.model.Folder"/>
</set>
</class>
<class name="citadon.bizcomponent.dms.model.Document" table="document" dynamic-update="true">
<id name="ObjectId" type="string" column="DocumentId" unsaved-value="null">
<generator class="assigned"/>
</id>
<many-to-one name="ParentFolder" column="FolderId" class="citadon.bizcomponent.dms.model.Folder" lazy="true"/>
</class>

When I tried to create the parent folder alone I am getting a Null Pointer exception for the collection (children). My requirement is that I will not be having any child at the time of creating the parent folder. Is there a way I can tell hibernate create only the parent and ignore creating the children. Also can I tell hibernate create only the child and ignore updating the parent.

I am struck with this issue. Could some one give me a pointer as to what can be done to overcome this issue.

thanks, TM

_________________
TM


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 11:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
I am getting a Null Pointer exception

How about posting the stack trace for this NullPointerException. Hibernate will not care if a collection is null; most likely your code is trying to do something with the collection.


Top
 Profile  
 
 Post subject: Stack Trace
PostPosted: Wed Oct 29, 2003 10:12 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:47 pm
Posts: 21
Steve,
Here is the stack trace.

<StackTrace>java.lang.Exception: java.lang.NullPointerException
at net.sf.hibernate.collection.CollectionPersister.writeIndex(CollectionPersister.java:412)
at net.sf.hibernate.collection.ArrayHolder.writeTo(ArrayHolder.java:115)
at net.sf.hibernate.collection.CollectionPersister.recreate(CollectionPersister.java:636)
at net.sf.hibernate.impl.ScheduledCollectionRecreate.execute(ScheduledCollectionRecreate.java:23)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2133)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2098)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2038)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:57)
at citadon.platform.global.ProjectnetTransaction.commit(ProjectnetTransaction.java:344)
at citadon.bizcomponent.dms.service.FolderServicesBean.createFolders(FolderServicesBean.java:276)
at citadon.bizcomponent.dms.service.FolderServicesBean_n3ivik_EOImpl.createFolders(FolderServicesBean_n3ivik_EOImpl.java:709)
at citadon.bizcomponent.dms.service.FolderServicesBean_n3ivik_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:305)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:274)
at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:167)
at weblogic.rmi.internal.ServerRequest.sendOneWayRaw(ServerRequest.java:92)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:112)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:262)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:229)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy250.createFolders(Unknown Source)
at citadon.bizcomponent.dms.adaptor.FolderAdaptor.createFolder(FolderAdaptor.java:253)
at citadon.bizcomponent.dms.adaptor.FolderAdaptor.processRequest(FolderAdaptor.java:152)
at citadon.bizcomponent.dms.adaptor.DmsAdaptor.processRequest(DmsAdaptor.java:64)
at java.lang.reflect.Method.invoke(Native Method)
at citadon.platform.service.projectnetservlet.CitadonSoapServlet.doPost(CitadonSoapServlet.java:200)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2546)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2260)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

at citadon.platform.global.ProjectnetTransaction.commit(ProjectnetTransaction.java:361)
at citadon.bizcomponent.dms.service.FolderServicesBean.createFolders(FolderServicesBean.java:276)
at citadon.bizcomponent.dms.service.FolderServicesBean_n3ivik_EOImpl.createFolders(FolderServicesBean_n3ivik_EOImpl.java:709)
at citadon.bizcomponent.dms.service.FolderServicesBean_n3ivik_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:305)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:274)
at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:167)
at weblogic.rmi.internal.ServerRequest.sendOneWayRaw(ServerRequest.java:92)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:112)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:262)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:229)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy250.createFolders(Unknown Source)
at citadon.bizcomponent.dms.adaptor.FolderAdaptor.createFolder(FolderAdaptor.java:253)
at citadon.bizcomponent.dms.adaptor.FolderAdaptor.processRequest(FolderAdaptor.java:152)
at citadon.bizcomponent.dms.adaptor.DmsAdaptor.processRequest(DmsAdaptor.java:64)
at java.lang.reflect.Method.invoke(Native Method)
at citadon.platform.service.projectnetservlet.CitadonSoapServlet.doPost(CitadonSoapServlet.java:200)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2546)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2260)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

thanks,
TM

_________________
TM


Top
 Profile  
 
 Post subject: More information
PostPosted: Wed Oct 29, 2003 10:25 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:47 pm
Posts: 21
The following is the sql trace of the Hibernate.

Hibernate: insert into folder (ObjectName, ObjectType, Name, Revision, VaultName, Policy, ObjectOwner, Grantee, Originated, Modified, Description, LastAction, LastActionDateTime, LastActionUserId, Status, Path, LinkType, OldStatus, CaXML, CaDefnId, Title, LockStatus, SearchKeyword, Notify, ReasonForLock, EntityType, ParentType, ContentObjectType, ElementType, ElementExists, ParentId, SpaceId, FolderId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update document set FolderId=null where FolderId=?
Hibernate: update folder set ParentId=null where ParentId=?
Hibernate: update document set FolderId=null where FolderId=?
Hibernate: update folder set ParentId=null where ParentId=?
Hibernate: update folder set ParentId=? where FolderId=?

I am surprised to see the updates for child folders and child documents even though there is no child folder or child document in the parent folder being created.

thanks,
TM

_________________
TM


Top
 Profile  
 
 Post subject: Need help
PostPosted: Thu Oct 30, 2003 2:27 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:47 pm
Posts: 21
I could not figure out how to prevent the updates to children or querying the children when the transaction is commited for a PARENT-CHILD (one-to-many) relation. Could some one let me know is it possible in hibernate and if so how can this be done. I am kind of struck with this issue as quite a number of our relations are PARENT-CHILD.

thanks,
TM

_________________
TM


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 5:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
I could not figure out how to prevent the updates to children or querying the children when the transaction is commited for a PARENT-CHILD (one-to-many) relation.

Please read the documentation. This is covered very explicitly.


Top
 Profile  
 
 Post subject: Resolved
PostPosted: Fri Oct 31, 2003 3:15 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:47 pm
Posts: 21
This issue was resolved by making the parent-child as bidirectional.
Thanks Gavin.

_________________
TM


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.