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.  [ 2 posts ] 
Author Message
 Post subject: organization of mapping files
PostPosted: Fri Oct 28, 2005 12:57 am 
Beginner
Beginner

Joined: Thu Feb 03, 2005 10:42 pm
Posts: 30
This is probably a silly question. But I am hibernatizing a huge app and I have tons of classes, I am organizing them into different hibernate mapping files. However I have come across instances where I have a class mapping in one file but need access to it in another file.

I always get this error:
Quote:
An association from the table blahblahblah refers to an unmapped class error.


If i then put that mapping in the file i have to move others and next thing you know all my mappings are in the same file. I am using spring and when I create my session factory I am doing it with all the files like so:

Code:
   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource"><ref local="dataSource"/></property>
      <property name="mappingResources">
         <list>
            <value>file1.hbm.xml</value>
            <value>file2.hbm.xml</value>
         </list>


I figured that hibernate would be ok with the references but apparently not. Is there a way to do this, i looked in the documentation but didn't see anything?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 1:07 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
the typical scenario is to go with one class, one mapping file. the mapping files go in the same directory/package as the class . for example, if your model consisted of com.foo.DJ and org.foo.TurnTable, you would have this in hibernate.cfg.xml

<mapping resource="com/foo/DJ.hbm.xml" />
<mapping resource="org/foo/TurnTable.hbm.xml" />

keep in mind that any reference to the other class would need the full class name because they are not in the same package.


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