-->
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/Eclipse multiple projects best practice?
PostPosted: Fri Dec 07, 2007 12:19 pm 
Beginner
Beginner

Joined: Mon Aug 22, 2005 1:22 am
Posts: 36
There was a post earlier this year about this but no response. So thought I would try the topic again.

We have multiple projects in eclipse (common utility vs app specific). Stuff in common is to be used across multiple apps, i.e. Country and State classes. We define the Hibernate mapping in the common project but want to utilize them in the apps without having to copy the .hbm.xml files to each app project.

Has anyone else come across this scenario? What was your solution to this problem?

Note: we don't have a 1-to-1 hbm.xml to Java class...we have grouped common classes in a single hbm.xml. So in the example above, we have State and Country in a State.hbm.xml file.

Thanks in advance
- Doug


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 1:05 pm 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

In eclipse, go to java buildpath and associate the common project required for your application specific project. i.e) select the "Required projects on the build path" in Projects tab of Java build path. So this will make your classes and hbm files available to your application projects.

And now comes the bigger one. You should use seperate hibernate.cfg.xml for common project and create several hibernate.cfg.xml for application project if your backend of common project and application project are different.

If both the common and application project use the same database. then in your extend the HibernateUtil class of common project create you own class to add the .hbm files of application project.

I'm giving you my opinion, i feel it is possible.

Hope this helps:-)

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 1:15 pm 
Beginner
Beginner

Joined: Mon Aug 22, 2005 1:22 am
Posts: 36
I have already "linked" the common project to my app project.

In my app hibernate.cfg.xml I have the following mapping entry:

<mapping resource="com/company/common/hib/domain/State.hbm.xml" />

but this is located in my common projects.

Is there a mapping entry that indicates to use a resource in a given package, i.e.

<mapping package="com.company.common.hib.domain" resource="State.hbm.xml" />

or something equivalent?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 1:23 pm 
Beginner
Beginner

Joined: Mon Aug 22, 2005 1:22 am
Posts: 36
Never mind ... it did work as expected. My inadequate researching the error.

Thanks for the help!


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.