-->
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: "Including" mappings for a sub-project
PostPosted: Thu Apr 27, 2006 4:33 am 
Newbie

Joined: Wed Apr 26, 2006 11:39 am
Posts: 8
Location: bracknell, UK
Is there any way to create mapping documents that "include" other mapping documents?

I'm looking for the ability to create a single mapping file that uses some sort of include directive to combine all the per-class mapping files in a sub-project, so I can then save effort by referencing this one file from the hibernate.cfg.xml when I draw together sub-projects (components) into a finished project.

(I'm stuck with per-class mapping files rather than one huge file, because that's how the eclipse hibernate plugin generates them.)

Worst case I can do this by referencing all the per-class mappings one after the other in the hibernate.cfg.xml, I know this. I'd prefer a more elegant solution if one existed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 1:16 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
No, you can't do that, unforunately. However, you can load multiple configuration files. My solution to exactly this problem was to configure hibernate with mulitple configuration files: one for the application properties (JDBC connections, show_sql="true", etc.), then one for each jar that uses hibernate and the app needs.

Here's a little sample code. sPath is the application's normal .cfg.xml file. mapFiles is a List of names of config files with <mapping> tags, though any confg file is allowed. I get that list from an XML file that configures my app.. you can make it any way you like.
Code:
      org.hibernate.cfg.Configuration hibConfig =
        new org.hibernate.cfg.Configuration().configure(sPath);

      for (String mapFile : mapFiles)
      {
        hibConfig.configure(mapFile);
      }

      m_FactSession = hibConfig.buildSessionFactory();

_________________
Code tags are your friend. Know them and use them.


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.