-->
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: question on multiple datasources
PostPosted: Tue Mar 29, 2005 5:23 pm 
Newbie

Joined: Tue Mar 29, 2005 5:09 pm
Posts: 3
hi,

i'm writing a portlet that will run in jboss (3.2.6). i have tested the portlet separately and it works with hibernate (2.1.8, i believe) just fine (connecting to mysql). the problem comes when i put the portlet in the portal.

the portal uses it's own database (oracle) and stores all the hibernate properties in system properties. i have my xml config file configured correctly and, i believe, loading correctly.

URL url = HibernateSessionFactory.class.getResource("/hibernate_test.cfg.xml");
log.info("Hibernate config file: " + url);
configuration = new Configuration().configure(url);

however, i keep getting oracle jdbc exceptions saying that the tables are not found. so i know that it's not using my configurations and it's still using the portal configurations.

from what i've read elsewhere, hibernate will look to the system properties, then to the xml config file, then to property files. i can clear out the system properties but then that causes all sorts of problems in the portal.

so my question is:
is there any way to force hibernate to look at a config file and ignore all datasources stored in the system properties?

thanks,
matt


Top
 Profile  
 
 Post subject: question on multiple datasources
PostPosted: Wed Mar 30, 2005 8:36 pm 
Newbie

Joined: Tue Mar 29, 2005 5:09 pm
Posts: 3
i really need some feed back on this issue. does anyone know how to force hibernate to look at a config file and ignore what is set in the system properties? or maybe alternative methods of accessing a second datasource through hibernate?

thanks,
matt


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 1:14 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 9:19 pm
Posts: 22
I believe you need to create another sessionfactory based on the new configuration .


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 1:42 pm 
Newbie

Joined: Tue Mar 29, 2005 5:09 pm
Posts: 3
thanks for the response.

i figured out the problem, though. you can wipe out the portal datasource properties by doing the following:

URL url = HibernateSessionFactory.class.
getResource("/hibernate_test.cfg.xml");

configuration = new Configuration()
.setProperties(new Properties())
.configure(url);

...

... configuration.buildSessionFactory();

...

and i thought that this wiped out the system properties for the portal because it i threw all sorts of exceptions after i created and closed the hibernate session.

turns out, the root of the exceptions was that when i was forwarding on to a JSP, i was overriding an attribute that the portal was using. really dumb mistake that had nothing to do with hibernate. many an hour beating my head into the wall for nothing.

hibernate works great and integrates well with portals and portlets can have all the independent datasources they want from their own config files. gotta love it.


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.