[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - One-to-Many mapping issue

chip_schoch do-not-reply at jboss.com
Tue Oct 14 15:29:09 EDT 2008


I have a situation where I have a one-to-many:

Document 1 ---> m DocumentVersion.

The document version has a composite-id.

    
  | <class name="com.eLynx.Core.Database.Entity.DocumentVersion"  
  |            table="DocumentVersion" 
  |            lazy="false">
  |     
  |         <composite-id >
  |     		<key-many-to-one name="document" 
  | 		                            column="ContentId" 
  |                         class="com.eLynx.Core.Database.Entity.Document"/>   		 
  | 		                           
  | 	          <key-property name="version" column="Version" type="int"/>                 
  |             <key-property name="mimeType" column="MimeType" type="string"/>
  |      	  </composite-id>
  |      	  
  | 		   <timestamp name="CreationDate" source="db" />
  | 		          
  |    	    <property name="CSFileId" type="long">
  |             <column name="CSFileId" not-null="true"/>
  |         </property>
  |        	  
  | </class>

The Document class is a subclass:

				
  | <!-- Document subclass definition -->
  | <subclass name="com.eLynx.Core.Database.Entity.Document"
  |                discriminator-value="D">
  | 				
  |       <list name="DocumentVersions" 
  |              table="DocumentVersion" 
  |              inverse="true" 
  |              cascade="all">
  | 		
  |            <key column="ContentId"/>
  |            <index column="version"/>
  |            <one-to-many class="com.eLynx.Core.Database.Entity.DocumentVersion"/
  |        </list>  
  | 	    		
  | </subclass>
				
I have test data where a document has one version.  When I do the load from:

           
  | Document root = (Document) session.load (Document.class, 146L);
  | List<DocumentVersion> versions = root.getDocumentVersions();
  | 

then examine the list in the debugger I see:

  | [null, com.eLynx.Core.Database.Entity.DocumentVersion at a576d0d9]

I cannot, for the life of me, figure out why I have that null in the first position.  Anyone have any ideas?  Thanks in advance.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4182233#4182233

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4182233



More information about the jboss-user mailing list