-->
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: Generic Question about Hibernate Development
PostPosted: Sun Oct 31, 2010 1:10 am 
Newbie

Joined: Sun Oct 31, 2010 12:59 am
Posts: 2
Hi All,

we are working on a web application where my team is responsible for the development of the core functionality of the application and development of ORM layer is the main area of concentration.

We have already pointed out all the major entities and other main component with respect to persistence layer and have started out implimentation for the same.
there is one area where we are still not able to find a good workaround,Since we are developing this core functionaity so we at some time willprovide this module as jar package to the other team who is responsible for other part of application,though we have already fingured alomost all required entities but still there are always chances that in future the other team needs to create some additional entities and we don't want them to have direct depedency on us.

Can some one suggest whats the best way so that when they create an new entity this should get register with out cfg file so that they need not to create any new cfg file.intentions are they only need to create the Entity class and its Mapping file(.hbm) and rest of the things should be taken care by out core module like identify new hbm file and registering it with configuration object etc.

Any help in this regard will be much appriciated

Thanks in advance
Travellingrants


Top
 Profile  
 
 Post subject: Re: Generic Question about Hibernate Development
PostPosted: Sun Oct 31, 2010 7:21 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you can start Hibernate programmatically from a Configuration object, in case you point it to all configuration files you want. You could have a conventional name for each of your .hbm files and have your startup code look for all resources having that name (which would load them from different jars), pass them all to the configuration object, and have your SessionFactory started.

second option, use annotations with autodiscovery of annotated entity classes (JPA)

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Generic Question about Hibernate Development
PostPosted: Mon Nov 01, 2010 1:17 am 
Newbie

Joined: Sun Oct 31, 2010 12:59 am
Posts: 2
Thanks for the input..
Can you please give me a pointer about the first option that will help me to get the idea in better way

Thanks
Travellingrants


Top
 Profile  
 
 Post subject: Re: Generic Question about Hibernate Development
PostPosted: Mon Nov 01, 2010 8:45 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Programmatic configuration is powerful, there are many options you can use (shouldn't need all of them) :

Code:
new org.hibernate.cfg.Configuration.Configuration()
   .addDirectory( File directory ) //search all hbm.xml files from a directory
   .addJar( File jar ) //searches all *.hbm.xml files in the jar and adds them to configuration
   .addFile( File xmlFile ) //adds mapping from a specific file
   .setProperty( Environment.DRIVER, "jdbc driver name" )
   .setProperty( Environment.URL, "jdbc url" )
   .setProperty( Environment...., "more options )")
   .buildSessionFactory();


I think you could define some convention which is most practical for you use case.
Maybe some properties can be hard-coded in such a SessionFactory factory, but you could read some options from you own configuration properties file.

_________________
Sanne
http://in.relation.to/


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.