Code:
@Entity
@Table(name = "table1", uniqueConstraints = @UniqueConstraint(columnNames = "table1ID"))
public class Table1 implements java.io.Serializable {
/**
* Serial Id of the class.
*/
private static final long serialVersionUID = 4098136300929982619L;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "table1ID", unique = true, nullable = false)
private Long table1ID = DatabaseConstants.INVALID_VALUE;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "table2")
private Set<Table2> table2 = new HashSet<table2>(0);
}
@Entity
@Table(name = "table2", uniqueConstraints = @UniqueConstraint(columnNames = "table2ID"))
public class Table2 implements java.io.Serializable {
/**
* Serial Id of the class.
*/
private static final long serialVersionUID = 5395459647729458145L;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "table2ID", unique = true, nullable = false)
private Long table2ID = DatabaseConstants.INVALID_VALUE;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "table1ID", nullable = false)
private Table1 table1;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "table3")
private Set<Table3> table3 = new HashSet<table3>(0);
}
@Entity
@Table(name = "table3", uniqueConstraints = @UniqueConstraint(columnNames = "table3ID"))
public class Table3 implements java.io.Serializable {
/**
* Serial Id of the class.
*/
private static final long serialVersionUID = 5395459647729458145L;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "table3ID", unique = true, nullable = false)
private Long table3ID = DatabaseConstants.INVALID_VALUE;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "table2ID", nullable = false)
private Table2 table2;
}
insertTable2(Table2 table2){
this.userTxn.begin();
this.entityManager.persist(table2);
this.entityManager.flush();
this.userTxn.commit();
}
getting below error when i try to insert a record in table2
javax.ejb.EJBException: Application error: BMT stateless bean OperationDaoBean should complete transactions before returning (ejb1.1 spec, 11.6.1)
at org.jboss.ejb3.tx.StatelessBMTInterceptor.checkStatelessDone(StatelessBMTInterceptor.java:86)
at org.jboss.ejb3.tx.StatelessBMTInterceptor.handleInvocation(StatelessBMTInterceptor.java:112)
at org.jboss.ejb3.tx.BMTInterceptor.invoke(BMTInterceptor.java:57)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
i did not get any error while insert data in table1, getting above error while inserting in table2 only
getting same error with and without @TransactionAttribute(TransactionAttributeType.REQUIRED)
please help me on this