-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to build an EntityManagerFactory in JSE?
PostPosted: Mon Jan 14, 2008 11:30 pm 
Newbie

Joined: Tue Dec 19, 2006 4:14 am
Posts: 8
I used to use Spring with Hibernate in JSE. But now I need to only use Hibernate in JSE. I read the Hibernate Entity Manger reference and searched the internet, but I do not find how to create an entity manager factory in JSE.

Could you kindly tell me where to find the material to do it?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 4:16 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi,

I have done the following before

Code:
EntityManagerFactory factory =
         Persistence.createEntityManagerFactory(pPersistenceUnitName);


The only thing you have to do to get the above to work is to have a META-INF folder in the classpath containing the persistence.xml

Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 4:32 am 
Newbie

Joined: Tue Dec 19, 2006 4:14 am
Posts: 8
Thanks for your reply.

But the problem is that the JDBC connection is hard-coded in the xml file. It is difficult to change it by the user when the application is released to the user. We have a UI to let the user select the type of the database servers.

Can the properties file be used?

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 5:53 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi,

I am not certian if properties can be used, but you can build an entitymanager factory programatically with an Ejb3Configuration object, this should give you the functionality you need.

Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 8:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes hibernate.properties can be used.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 8:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I mean in conjunction with persistence.xml

_________________
Emmanuel


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