-->
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.  [ 2 posts ] 
Author Message
 Post subject: Clarification needed properties
PostPosted: Thu Oct 06, 2005 2:55 pm 
Hello,

Upon trying to get underway with hibernate (specifically setting up with Tomcat and Struts). I have found many, many examples of obtaining a sessionFactory object.

Currently I have two different approaches. ####

1) singleton class obj:
Configuration cfg = new Configuration().addClass(Track.class).
addClass(Artist.class);
sessionFactory = cfg.buildSessionFactory();

And in order for that to work, I put a fiile called "hibernate.properties" in classes with this information:
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/notebook_db
hibernate.connection.username=jim
hibernate.connection.password=s3cret
-- and it works like a champ. ----

2) Another configuration I have is a struts plug in from article here <http://www.hibernate.org/105.html>
uses a struts plug in, but uses a 'hibernate.cfg.xml' file under /classes.

I really like the ability to use the hibernate.cfg.xml file, because I can add mappings without compiling. So I would like to know how I can configure the singleton class above to use that instead of the one it is automatically picking up.

Thanks,


Top
  
 
 Post subject: Re: Clarification needed properties
PostPosted: Thu Oct 06, 2005 3:41 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Code:
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml);
sessionFactory = cfg.buildSessionFactory();


hibernate.cfg.xml must be in your classpath.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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