JBoss 4.2.2.GA Hibernate configuration through JTA throws no
madhuranjans Oct 21, 2008 9:58 AMI am trying to configure JTA based Transaction for Hibernate on JBoss-4.2.2.GA. When I call persist nothing happens. When i put a flush after persist it throws javax.persistence.TransactionRequiredException: no transaction is in progress.
Below are the configurations and others:
persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="Manager1" transaction-type="JTA">
org.hibernate.ejb.HibernatePersistence
<jta-data-source>java:/CRUISELIVE_DS</jta-data-source>
<!--<mapping-file>ormap.xml</mapping-file>-->
<jar-file>hibernate-ejb3-orm.jar</jar-file>
com.thunder.gds.core.orm.hibernate.Account
<!---->
</persistence-unit>
Content of Account.java class
@Entity
@Table(name="Account"
,schema="dbo"
,catalog="cruiselive"
)
public class Account implements java.io.Serializable {
private int ID;
private BigDecimal amt;
private String name;
public Account() {
}
public Account(int ID) {
this.ID = ID;
}
public Account(int ID, BigDecimal amt, String name) {
this.ID = ID;
this.amt = amt;
this.name = name;
}
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="ID", unique=true, nullable=false)
public int getID() {
return this.ID;
}
public void setID(int ID) {
this.ID = ID;
}
@Column(name="amt", precision=12, scale=4)
public BigDecimal getAmt() {
return this.amt;
}
public void setAmt(BigDecimal amt) {
this.amt = amt;
}
@Column(name="name")
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
Code Where I am trying to execute and I am getting error:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("Manager1");
EntityManager em = emf.createEntityManager();
ac = new Account();
ac.setName("Madhu" + new Date());
ac.setAmt(new BigDecimal("50.45"));
em = emf.createEntityManager();
em.persist(ac);
em.flush();
em.close();
I tried all possible things but did not able to start the transaction. What step i am missing. Please help me resolve. My database is SQL Server 2005.