-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate and Application Architecture
PostPosted: Sun Jul 30, 2006 9:10 pm 
Beginner
Beginner

Joined: Wed Mar 01, 2006 11:26 pm
Posts: 23
Hi there

I am wondering if the following is possible and also good practice.

My idea is to produce a single hibernate API jar that would be made available to any application wishing to access our db applications This seems to make sense on a design/maintence level.

My problem was how to make all mapping documents available to the hibernate API.

Would I have to reference all jars wishing to make use of the API on the classpath and then manually add all of the mapping resources to the API cfg.xml document? Is there a more dynamic way off approaching this?

Is there a mapping resource of sorts? Ie in a project can I group together all mapping resources requiurd for that development and then make this single resource available to the Hibernate API?

Any advice or a nudge in the direction of any reading material on this is greatly recieved

Thanks

Chris


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 4:51 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
I believe if you use "Configuration.addResource(Class c)" Hiberate will try to look for the Mapping XML in the same location as the Class file (i.e. in the fully qualified path of the class".

So for e.g. let's say you had a class whose name was foo.bar.Persist1

Then if you do

config.addResource(foo.bar.Persist1.class);

Hibernate will look for the XML file at:

<CLASSPATH>/foo/bar/Persist1.hbm.xml

Hope that helps.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 7:43 pm 
Beginner
Beginner

Joined: Wed Mar 01, 2006 11:26 pm
Posts: 23
Thanks for that. I was hoping for something a bt more generic.

I.e add a resource from the classpath that contains all of mappings for a sperate project rather than a reference to each individual mapping file.

Is it bad practice to have a single session manager for all projects to use but for each project to have its own hibernate.cf.xml document containing its own connection, properties and mapping profiles? Would this cause any problems?

Any help on this is welcome. There doesnt seem to be any documentation on this subject.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 1:29 am 
Beginner
Beginner

Joined: Wed Mar 01, 2006 11:26 pm
Posts: 23
Thanks to tenwits answer on another post I have managed to solve this issue.

It appear you can use a <mapping jar=foo.jar> tag to import all of the *.hbm.xml documents from a given jar.


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