Does anyone know how can i connect EJB + Hibernate?
Or is somewhere tutorial how to make this?
Please some help :).
Luk
-
How connect EJB + Hibernate (4 messages)
- Posted by: Lukasz Luk
- Posted on: August 04 2005 08:50 EDT
Threaded Messages (4)
- How connect EJB + Hibernate by Rajesh K. Ilango on August 04 2005 15:26 EDT
- How connect EJB + Hibernate by Lukasz Luk on August 05 2005 03:18 EDT
- How connect EJB + Hibernate by Rajesh K. Ilango on August 05 2005 09:24 EDT
- And Jonas ? by Time PassX on August 26 2005 10:02 EDT
-
How connect EJB + Hibernate[ Go to top ]
- Posted by: Rajesh K. Ilango
- Posted on: August 04 2005 15:26 EDT
- in response to Lukasz Luk
Which Application server are you using?
regards,
Rajesh Kumar Ilango -
How connect EJB + Hibernate[ Go to top ]
- Posted by: Lukasz Luk
- Posted on: August 05 2005 03:18 EDT
- in response to Rajesh K. Ilango
I'm using JBoss 3.0.8 + MySql.
Thanks,
Luk. -
How connect EJB + Hibernate[ Go to top ]
- Posted by: Rajesh K. Ilango
- Posted on: August 05 2005 09:24 EDT
- in response to Lukasz Luk
Follow the steps:
1. Create jBoss-Hib-Service.xml and put it in the deploy directory. The purpose is to create a service and register at JNDI, so that it can use to interact with DB using Hibernate.
Following is an example(This I generate using xDoclet.):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateLaborMgmt">
<depends>jboss.jca:service=RARDeployer</depends>
<attribute name="MapResources">org/learn/labormgmt/employee/value/EmployeeValues.hbm.xml,org/learn/labormgmt/customer/value/CustomerValues.hbm.xml,org/learn/labormgmt/location/value/StateValues.hbm.xml,org/learn/labormgmt/association/value/AssociationValues.hbm.xml</attribute>
<attribute name="JndiName">java:/hibernate/labormgmt</attribute>
<attribute name="Datasource">java:/labormgmt</attribute>
<attribute name="Dialect">org.hibernate.dialect.SAPDBDialect</attribute>
<attribute name="ShowSql">true</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
</mbean>
</server>
2. In the code get the service, which is actually a Session factory. e.g. code:
try {
//JNDI lookup to get Hibernate Session factory.
SessionFactory factory = (SessionFactory)ServiceLocator.getInstance()
.getService("java:/hibernate/labormgmt");
} catch (HibernateException e) {
logger.debug("Error while initilising Hibernate." + e.getMessage());
throw new InstantiationError("Error while initilising Hibernate."
+ e.getMessage());
} catch (LocatorException e) {
logger.debug("Error while initilising Hibernate." + e.getMessage());
throw new InstantiationError("Error while initilising Hibernate."
+ e.getMessage());
}
3. Start using it for creating Hibernate Session.
Session session = null;
session = factory.openSession();
I hope it helps you.
Regards,
Rajesh Kumar Ilango -
And Jonas ?[ Go to top ]
- Posted by: Time PassX
- Posted on: August 26 2005 10:02 EDT
- in response to Rajesh K. Ilango
Same question with Jonas server ...
Ways more difficult to find than Jboss outhere !