Close

XADatasource in JBossAS & Hibernate

If you have ever wondered how you can use an XA Datasource in your JBoss AS, this is the answer. First you need to define the XA Datasource in your JBossAS, it is as easy as creating an XML file like this: XAOracleDS true false oracle.jdbc.xa.client.OracleXADataSource jdbc:oracle:thin:@monkeymachine:1521:jboss jboss password org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter jboss:service=TransactionManager Then you need to…

Hibernate First Steps

For adding a new object (to database) the code below suffice (you still need to define xml files / JPA annotation still for hibernate configuration): Configuration conf = new Configuration().configure(file);SessionFactory sessionFactory = conf.buildSessionFactory();session =sessionFactory.openSession();//Create new instance of Contact and set values in it by reading them from form object Transaction tx;tx = session.beginTransaction(); System.out.println(“Inserting Record”);contact…