I have two Antrag objects (application) and Anlage (object). An application can be made for several objects. The application is saved directly in the DAO. Funds are saved through the cascade.
@Entity
@Table(name = "EEG_ANTRAG")
public class Antrag implements Serializable {
private static final long serialVersionUID = -2440344011443487714L;
@Id
@Column(name = "ANT_ID", nullable = false)
@SequenceGenerator(name = "sequenceGeneratorAntrag", sequenceName = "EEG_ANTRAG_SEQ", allocationSize = 1)
@GeneratedValue(generator = "sequenceGeneratorAntrag")
@Getter @Setter private Long id;
@OneToMany(mappedBy = "antrag", cascade = { CascadeType.ALL }, orphanRemoval = true)
@OrderBy("id ASC")
@Getter private List<Anlage> anlageList = new ArrayList<Anlage>();
public Anlage addAnlage(Anlage anlage)
anlageList.add(anlage);
anlage.setApplication(this);
return anlage;
}
}
@Entity
@Table(name = "EEG_ANLAGE")
public class Anlage implements Serializable {
private static final long serialVersionUID = -3940344011443487741L;
@Id
@Column(name = "ANL_ID")
@SequenceGenerator(name = "sequenceGeneratorAnlage", sequenceName = "EEG_ANLAGE_SEQ", allocationSize = 1)
@GeneratedValue(generator = "sequenceGeneratorAnlage")
@Getter @Setter private Long id;
@ManyToOne
@JoinColumn(name = "ANL_ANT_ID")
@Getter @Setter private Antrag antrag;
}
@Stateless
public class AntragDaoBean implements AntragDaoLocal {
@PersistenceContext(unitName = "ejb-model")
private EntityManager em;
@Override
public void persistAntrag(Antrag antrag) {
em.persist(antrag);
}
}
When an error occurs while inserting funds, for example. some column name is written with an error in essence, an exception is thrown. The column indicates that a rollback has been performed. The problem is that the application is still being saved. Shouldn't I roll back application application? We are using EclipseLink 2.4.1. The EclipseLink debug output indicates that all insertions are performed in a single transaction. The database is Oracle 11g. Is my assessment of transactional behavior incorrect? How do I get the behavior I want?
EvaluationException:
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
EJBTransactionRolledbackException:
org.jboss.as.ejb3.tx.CMTTxInterceptor.handleEndTransactionException(CMTTxInterceptor.java:115)
RollbackException:
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)
DatabaseException:
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
SQLSyntaxErrorException:
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)