I have the following in a SFSB:
| public void saveOrder() {
|
| try {
| if (order.getId() != null) {
| entityManager.merge(order);
| FacesUtil.addInfoMessage("Order Number: " + order.getOrderNumber()
+" was successfully updated.");
| } else {
| entityManager.persist(order);
| FacesUtil.addInfoMessage("Your Order Number is: " +
order.getOrderNumber());
| }
| //entityManager.flush();
| //events.raiseTransactionSuccessEvent("orderCreated");
| //editOrder();
| } catch (IllegalStateException se) {
| se.fillInStackTrace();
| FacesUtil.addInfoMessage("Test ....");
| } catch (Exception e) {
| FacesUtil.addInfoMessage("Test2 ....");
| }
| }
and this listener on the order object:
public class OrderValidator {
|
| @PrePersist @PreUpdate
| public void validateSubmit(Order order) {
| if (order.getStatus() == Status.SUBMITTED) {
| if (order.getUploadFileList().size() < 1) {
| throw new IllegalStateException("Submitted orders must have at least one
attachment.");
| }
| }
| }
| }
When I try and get it to fail via persist, everything works fine and I get my
FacesMessage. When I try and get it to fail via merge I get:
[arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2]
TwoPhaseCoordinator.beforeCompletion - failed for
com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@6c43e2
| javax.persistence.PersistenceException: java.lang.IllegalStateException: Submitted
orders must have at least one attachment.
| at
org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:527)
|
and it never reaches either catch block in my SFSB. What gives?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4157198#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...