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.  [ 3 posts ] 
Author Message
 Post subject: loading mappings automatically
PostPosted: Tue Dec 20, 2005 12:38 pm 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Hibernate version: 3.x

Hello.

We have here several subproject, all subproject result in a .jar containing various classes and some .hbm.xml mapping files

Then we have other projects (let's call them main projects), which use those .jar. In those other projects, we need to load hibernate configuration, this include all *.hbm.xml files present in those jar.

Assuming all those .jar are in classpath (WEB-INF/lib), we could use lots of
Code:
<mapping ressource="bla/bla.hbm.xml"/>

in our hibernate.cfg.xml. But it's not very easy to manage. If there are changes in a subproject (eg, one additionnal class 'X'), we need to add a corresponding mapping tag to all main projects.

It would be interresting if there was some way to have hibernate do things like 'Ok, need to use class X, let's explore the classpath ressources to find it's mapping', but all i see is either list mappings in main config file, either do some addClass() in main projects.

Is there some way to have hibernate related changes in subprojects automatically reflected to main projects (just update the .jar and it's done)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 4:58 pm 
Newbie

Joined: Wed Sep 17, 2003 5:36 pm
Posts: 5
Hi tchize,

If you are using Spring to configure Hibernate, you can actually specify the jar that contains the mapping files, and it will find all the mapping files automatically. For example, my Spring configuration for Hibernate is:

Code:
   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="mappingJarLocations">
         <value>WEB-INF/lib/sapphiredb.jar</value>
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
         </props>
...


Hope this help,
Ben


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 5:40 pm 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
No sorry, we are not using Spring. Hibernate is configured by hibernate.cfg.xml in a HibernateSessionFactory.

Moreover, names of jar are not so predictable. The whole project is managed by maven, and they looks like

WEB-INF/lib/RMI-Hibernate-<subproject>.<subprojectVersion>.jar


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