-->
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: Want to Construct session Factory using Datasource
PostPosted: Mon May 26, 2008 11:01 pm 
Newbie

Joined: Thu Jan 05, 2006 1:33 am
Posts: 6
HI,

I have a requirement to create hibernate session factory dynamically using the datasource. That means my database will be dynamically created, so we can't declare the datasource in mysql-ds.xml in the JBoss server. When system is trying to create the hibernate session factory we have to set the datasource dynamicaly and use it to create the session factory.

If anyone have idea on this, Please help me.

_________________
Krishna Srinivasan
Hibernate Tips
Hibernate Articles


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 11:44 pm 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
this code may be of help in this context..

Configuration lConf = new AnnotationConfiguration();
lConf.configure("/resources/hibernate.common.cfg.xml");
lConf.configure(
ConfigHelper.locateConfig("resources/hibernate.cfg.xml"));
sessionFactory = lConf.buildSessionFactory();

Basically look at Configurtion api of hibernate.. and its different impl..

Regards,
Nagendra

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 3:13 am 
Newbie

Joined: Thu Jan 05, 2006 1:33 am
Posts: 6
Your answer for creating simple hibernate session factory. But my requirement is to manipulate the datasource itself.

_________________
Krishna Srinivasan
Hibernate Tips
Hibernate Articles


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 3:29 am 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
Configuration interface has a way to manipulate its properties though methods such as mergeProperties(Properties properties)
and setProperty(String propertyName, String value)..

These methods should enable the overide of data source or any property which u may wish to change at run time

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 4:04 am 
Newbie

Joined: Thu Jan 05, 2006 1:33 am
Posts: 6
I understand that. But even if you override the datasource property, datasource is deployed in JBoss server only. how can I dynamicaly set the database name to datasource.

_________________
Krishna Srinivasan
Hibernate Tips
Hibernate Articles


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 4:38 am 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
Sorry.. krishna.. unable to understand your need further... in case you are blr.. you could call me.. so that we could discuss further..

My mobile : +91-9886723872.

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


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.