-->
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: hibernate 4.0 connection
PostPosted: Fri Dec 16, 2011 2:48 pm 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
I used this piece of code to get metadata from my Session using releases 3.x:
Code:
final DatabaseMetaData metaData = sesion.connection().getMetaData();

As connection method has been deprecated and discarded from release 4.0, how can I obtain same results using this new release?


Top
 Profile  
 
 Post subject: Re: hibernate 4.0 connection
PostPosted: Sun Dec 18, 2011 1:43 am 
Newbie

Joined: Sun Dec 18, 2011 12:47 am
Posts: 2
Version 4 is not working for ejb3Configuration. It is deprecated. I am using the Java method to program it in my java class. The Java file won't compile using version 4.

Ejb3Configuration ejb3Configuration = new Ejb3Configuration();

ejb3Configuration.setProperty("hibernate.c3p0.max_size", ("75"));
ejb3Configuration.setProperty("hibernate.c3p0.max_statements", ("10"));
ejb3Configuration.setProperty("hibernate.c3p0.min_size", ("05"));
ejb3Configuration.setProperty("hibernate.c3p0.timeout", ("1800"));
ejb3Configuration.setProperty("hibernate.connection.datasource", ("java:comp/env/jdbc/dbThis_rdbms"));
ejb3Configuration.setProperty("hibernate.connection.driver_class", ("com.mysql.jdbc.Driver"));
ejb3Configuration.setProperty("hibernate.connection.password", (""));
ejb3Configuration.setProperty("hibernate.connection.url", ("jdbc:mysql://Dbthishost/dbThis_rdbms"));
ejb3Configuration.setProperty("hibernate.connection.username", (""));
ejb3Configuration.setProperty("hibernate.current_session_context_class", ("thread"));
ejb3Configuration.setProperty("hibernate.dialect", ("org.hibernate.dialect.MySQLDialect"));
ejb3Configuration.setProperty("hibernate.order_updates", ("true"));
ejb3Configuration.setProperty("hibernate.show_sql", ("true"));
// ejb3Configuration.setProperty("hibernate.transaction.factory_class", ("org.hibernate.transaction.JDBCTransactionFactory"));
ejb3Configuration.setProperty("hibernate.session_factory_name", ("dbThisJPAFactory"));

// <provider>org.hibernate.ejb.HibernatePersistence</provider>

entityManagerFactory = ejb3Configuration.buildEntityManagerFactory();
entityManager = entityManagerFactory.createEntityManager();


Top
 Profile  
 
 Post subject: Re: hibernate 4.0 connection
PostPosted: Mon Oct 22, 2012 4:18 pm 
Newbie

Joined: Wed Jul 08, 2009 8:11 am
Posts: 8
jesusaplsoft wrote:
I used this piece of code to get metadata from my Session using releases 3.x:
Code:
final DatabaseMetaData metaData = sesion.connection().getMetaData();

As connection method has been deprecated and discarded from release 4.0, how can I obtain same results using this new release?


I too would like to know the answer to this.


Top
 Profile  
 
 Post subject: Re: hibernate 4.0 connection
PostPosted: Tue Oct 23, 2012 4:43 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
I solved it using Spring. I already was using it and I did not have to start a new learning curve.

Code:
final DatabaseMetaData metaData = getDataSource().getConnection().getMetaData();


Just in case you do not know how to get DataSource...
Code:
    protected static DataSource getDataSource() {
        return (DataSource) getBeanById("dataSource");
    }


Top
 Profile  
 
 Post subject: Re: hibernate 4.0 connection
PostPosted: Tue Oct 23, 2012 8:05 am 
Newbie

Joined: Wed Jul 08, 2009 8:11 am
Posts: 8
jesusaplsoft wrote:
I solved it using Spring. I already was using it and I did not have to start a new learning curve.

Code:
final DatabaseMetaData metaData = getDataSource().getConnection().getMetaData();


Just in case you do not know how to get DataSource...
Code:
    protected static DataSource getDataSource() {
        return (DataSource) getBeanById("dataSource");
    }


This answer seems very specific to your application. I need a Hibernate answer. We were able to get the Connection in the past from the Hibernate Session, and now we can't... so what am I supposed to do?


Top
 Profile  
 
 Post subject: Re: hibernate 4.0 connection
PostPosted: Tue Oct 23, 2012 8:24 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
Are you using Spring?


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.