-->
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.  [ 1 post ] 
Author Message
 Post subject: Oracle Application Server Containers for J2EE
PostPosted: Wed Jul 13, 2005 4:38 am 
Newbie

Joined: Mon Jul 11, 2005 4:35 am
Posts: 7
Hi

I'm using Oracle Application Server Containers for J2EE to run
my Hibernate application in. For this I've configured with help
from Hibernate in Action and the reference manual a hibernate.cfg.xml
as shown below. I'm also getting my session object from a HibernateUtil
class which returns a session object created by the SessionFactory
bound to JNDI. And it works!

What I want to know is what actually is happenning inside the app server.
My assumptions are the following

- The connection pooling is handled by the app server through JNDI.
- Container-managed transactions (CMT) are used through JTA. The Hibernate
Transaction interface is embedding JTA.

Seems my assumptions right?


<session-factory name="java:/hibernate/HibernateFactory">

<property name="connection.datasource">java:comp/env/jdbc/hibernate</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.OrionTransactionManagerLookup
</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>

</session-factory>



import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class HibernateUtil {

static {
try {
new Configuration().configure().buildSessionFactory();
}
catch (Throwable e) {
e.printStackTrace();
}
}

public static SessionFactory getSessionFactory() {
SessionFactory sessions = null;
try {
Context ctx = new InitialContext();
String jndiName = "java:/hibernate/HibernateFactory";
sessions = (SessionFactory)ctx.lookup(jndiName);
}
catch (NamingException e) {
e.printStackTrace();
}
return sessions;
}

public static Session getSession() throws HibernateException {
return getSessionFactory().openSession();
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.