8 Replies Latest reply on Aug 13, 2013 2:40 AM by Stephen Coy

    Insertion happened when update the record

    Mary Hansen Newbie

      In my JSF project with Seam3.2.2 integration, Update doesn't work. Instead update the value, it insert the new value in table.

      Please I need some help here.

       

      flow of my project.

      list.xhtml

       

      <s:link id="editUser" view="/updateUser.xhtml">
                                 
      <f:param name="userId" value="#{user.userId}" />
                                 
      <img id="edit-user-img" src="#{imagesPath}/edit-icon.png"
                                     
      alt="Edit user" title="Edit User" />
      </s:link>


      Pages.xml:

       


      <page  view-id="/updateUser.xhtml" action="#{userEditAction.setCurrentUser()}">
             
      <navigation>
                 
      <rule if-outcome="success">
                     
      <redirect view-id="/secure/admin/user/updateUser.xhtml"/>
                 
      </rule>
             
      </navigation>
             
      <begin-conversation join="true"></begin-conversation>
      </page>

       


      UserEditAction.java Bean:

       


      @RequestParameter
         
      private Integer userId;

         
      @Override
         
      public String setCurrentUser(){
             
      System.out.println("Selected  userid ----- " + userId);
              currentUser
      = userService.getUser(userId);
             
      return "success";
      }

       


      userUpdate.xhtml :

       


      <h:commandButton value="Update" tabindex="20"
                 
      action="#{userAction.update}">
                 
      <f:param name="userId" value="#{currentUser.userId}" />
      </h:commandButton>

       

      userAction.java Bean

       


      @Name("userAction")
      @Stateless
      @AutoCreate
      public class UserActionImpl implements UserAction {

         
      @Out(value = "currentUser", scope = ScopeType.CONVERSATION)
         
      @In(value = "currentUser", scope = ScopeType.CONVERSATION, required = false)
         
      private CLRPUser currentUser;  

         
      @In
         
      private UserService userService;   

         
      @RequestParameter
         
      private Integer userId;

         
      private static final long serialVersionUID = 8282995226262125676L;

         
      public String update() {
              userService
      .saveOrUpdate(currentUser);
             
      return "success";
      }

       


      userService.java:

       


      public Integer saveOrUpdate(CLRPUser user) {
             
      // TODO Validation...check cell phone number.. email id..
             
      // user.setLastUpdatedBy(currentUserId);
              user
      .setLastUpdatedBy(loggedInUser.getId());
              user
      .getResidentialAddress().setLastUpdatedBy(loggedInUser.getId());
              user
      .getShippingAddress().setLastUpdatedBy(loggedInUser.getId());

      }

       


      userMapper.java :

       


      public class UserMapper {

         
      public static UserEntity mapUserEntity(CLRPUser user) {
             
      UserEntity userEntity = new UserEntity();

              userEntity
      .setEmailAddress(user.getEmailAddress());
              userEntity
      .setFirstName(user.getFirstName());
              userEntity
      .setLastName(user.getLastName());
              userEntity
      .setHomeNumber(user.getHomeNumber());
              userEntity
      .setOfficeNumber(user.getOfficeNumber());
              userEntity
      .setCellNumber(user.getCellNumber());
             
      AuditInfo auditInfo = new AuditInfo();
              auditInfo
      .setLastUpdatedBy(user.getLastUpdatedBy());
              auditInfo
      .setLastUpdatedTime(user.getLastUpdatedTime());
              userEntity
      .setAuditInfo(auditInfo);
              userEntity
      .setType(user.getType());
              userEntity
      .setPreferenceId(user.getPreferenceId());
              userEntity
      .setASPCustomerId(user.getAspCustomerId());

              user
      .getResidentialAddress().setAddressType("R");
              user
      .getShippingAddress().setAddressType("S");
             
      AddressEntity residential = AddressMapper.mapAddressEntity(user
                     
      .getResidentialAddress());
             
      AddressEntity shipping = AddressMapper.mapAddressEntity(user
                     
      .getShippingAddress());
             
      List<AddressEntity> addressess = new ArrayList<AddressEntity>();
              addressess
      .add(residential);
              addressess
      .add(shipping);

              userEntity
      .setAddresses(new HashSet<AddressEntity>(addressess));

             
      /*UserLoginEntity userLogin = UserLoginMapper.mapUserLoginEntity(user.getUserLogin());
              List<UserLoginEntity> userLoginn = new ArrayList<UserLoginEntity>();
              userLoginn.add(userLogin);

              userEntity.setUserLogin(new HashSet<UserLoginEntity>(userLoginn));*/

             
      // userEntity.setCardTypeEntity(cardTypeEntity)
             
      return userEntity;
      }

       


      JPAUserDAO.java

       


      public Integer saveOrUpdate(UserEntity newUser) {      
              entityManager
      .merge(newUser);
             
      return newUser.getUserId();
      }


        • 1. Re: Insertion happened when update the record
          Stephen Coy Master

          This is really a Hibernate/JPA question, but my first instinct is to check that you have correctly implemented the equals and hashCode methods on your UserEntity.

          • 2. Re: Insertion happened when update the record
            Mary Hansen Newbie

            Thanks for your time Stephen, I am showing my user entity here for your reference..

             

            package com.ermms.clrp.entities;

             

            import java.io.Serializable;

            import java.util.Set;

             

            import javax.persistence.CascadeType;

            import javax.persistence.Column;

            import javax.persistence.Embedded;

            import javax.persistence.Entity;

            import javax.persistence.FetchType;

            import javax.persistence.GeneratedValue;

            import javax.persistence.GenerationType;

            import javax.persistence.Id;

            import javax.persistence.JoinColumn;

            import javax.persistence.JoinTable;

            import javax.persistence.ManyToOne;

            import javax.persistence.NamedQueries;

            import javax.persistence.NamedQuery;

            import javax.persistence.OneToMany;

            import javax.persistence.Table;

             

            @Entity

            @Table(name = "User")

            @NamedQueries(value = {

                    @NamedQuery(name = UserEntity.fetchAll, query = "FROM UserEntity"),

                    @NamedQuery(name = UserEntity.fetchByUserType, query = "FROM UserEntity where type=:type"),

                    @NamedQuery(name = UserEntity.fetchByUserId, query = "FROM UserEntity where userId = :id"),

                    @NamedQuery(name = UserEntity.fetchByFirstName, query = "FROM UserEntity where firstName like :fName AND type=:type"),

                    @NamedQuery(name = UserEntity.fetchByFirstNames, query = "FROM UserEntity where lastName like :lName"),

                    @NamedQuery(name = UserEntity.fetchByFirstAndLastName, query = "FROM UserEntity where firstName like :fName AND lastName like :lName"),

                    @NamedQuery(name = UserEntity.fetchByCellNumber, query = "FROM UserEntity where cellNumber = :cellNumber") })

            public class UserEntity implements Auditable, Serializable {

             

                private static final long serialVersionUID = -1736149934172089780L;

                public final static String fetchAll = "UserEntity.fetchAll";

                public final static String fetchByUserType = "UserEntity.fetchByUserType";

                public final static String fetchByUserId = "UserEntity.fetchByUserId";

                public final static String fetchByFirstName = "UserEntity.fetchByFirstName";

                public final static String fetchByFirstNames = "UserEntity.fetchByLastName";

                public final static String fetchByFirstAndLastName = "UserEntity.fetchByFirstAndLastName";

                public final static String fetchByCellNumber = "UserEntity.fetchByCellNumber";

             

                @Embedded

                private AuditInfo auditInfo;

             

                @OneToMany(cascade = CascadeType.ALL, targetEntity = com.ermms.clrp.entities.AddressEntity.class)

                @JoinTable(name = "useraddress", joinColumns = @JoinColumn(name = "userId", unique = true), inverseJoinColumns = @JoinColumn(name = "AddressId"))

                private Set<AddressEntity> addresses = null;

             

                @ManyToOne(fetch = FetchType.LAZY)

                @JoinColumn(name = "UserId", referencedColumnName = "CustomerId")

                private CustomerCardEntity customerCardEntity;

             

                @Id

                @GeneratedValue(strategy = GenerationType.IDENTITY)

                @Column(name = "userId", updatable = false)

                private Integer userId = null;

             

                @Column(name = "ASPCustomerId")

                private Integer ASPCustomerId;

             

                @Column(name = "EmailAddress")

                private String emailAddress;

             

                @Column(name = "FirstName")

                private String firstName;

             

                @Column(name = "LastName")

                private String lastName;

             

                @Column(name = "OfficePhoneNumber")

                private String officeNumber;

             

                @Column(name = "HomePhoneNumber")

                private String homeNumber;

             

                @Column(name = "CellNumber")

                private String cellNumber;

             

                @Column(name = "PreferenceId")

                private Integer preferenceId;

             

                @Column(name = "Type")

                private String type;

             

                @Column(name = "Deleted")

                private boolean deleted;

             

                /**

                 * private double height; private String education; private int familySize;

                 * private int numberOfChildren;

                 */

                /*

                 * (non-Javadoc)

                 *

                 * @see com.erms.clrp.model.Auditable#getAuditInfo()

                 */

                public AuditInfo getAuditInfo() {

                    return auditInfo;

                }

             

                /*

                 * (non-Javadoc)

                 *

                 * @see

                 * com.erms.clrp.model.Auditable#setAuditInfo(com.erms.clrp.model.AuditInfo)

                 */

                public void setAuditInfo(AuditInfo auditInfo) {

                    this.auditInfo = auditInfo;

             

                }

             

                /**

                 * @return the addresses

                 */

                public Set<AddressEntity> getAddresses() {

                    return addresses;

                }

             

                /**

                 * @param addresses

                 *            the addresses to set

                 */

                public void setAddresses(Set<AddressEntity> addresses) {

                    this.addresses = addresses;

                }

             

                /**

                 * @return the userId

                 */

                public Integer getUserId() {

                    return userId;

                }

             

                /**

                 * @param userId

                 *            the userId to set

                 */

                public void setUserId(Integer userId) {

                    this.userId = userId;

                }

             

                /**

                 * @return the aSPCustomerId

                 */

                public Integer getASPCustomerId() {

                    return ASPCustomerId;

                }

             

                /**

                 * @param aSPCustomerId

                 *            the aSPCustomerId to set

                 */

                public void setASPCustomerId(Integer aSPCustomerId) {

                    ASPCustomerId = aSPCustomerId;

                }

             

                /**

                 * @return the emailAddress

                 */

                public String getEmailAddress() {

                    return emailAddress;

                }

             

                /**

                 * @param emailAddress

                 *            the emailAddress to set

                 */

                public void setEmailAddress(String emailAddress) {

                    this.emailAddress = emailAddress;

                }

             

                /**

                 * @return the firstName

                 */

                public String getFirstName() {

                    return firstName;

                }

             

                /**

                 * @param firstName

                 *            the firstName to set

                 */

                public void setFirstName(String firstName) {

                    this.firstName = firstName;

                }

             

                /**

                 * @return the lastName

                 */

                public String getLastName() {

                    return lastName;

                }

             

                /**

                 * @param lastName

                 *            the lastName to set

                 */

                public void setLastName(String lastName) {

                    this.lastName = lastName;

                }

             

                /**

                 * @return the officeNumber

                 */

                public String getOfficeNumber() {

                    return officeNumber;

                }

             

                /**

                 * @param officeNumber

                 *            the officeNumber to set

                 */

                public void setOfficeNumber(String officeNumber) {

                    this.officeNumber = officeNumber;

                }

             

                /**

                 * @return the homeNumber

                 */

                public String getHomeNumber() {

                    return homeNumber;

                }

             

                /**

                 * @param homeNumber

                 *            the homeNumber to set

                 */

                public void setHomeNumber(String homeNumber) {

                    this.homeNumber = homeNumber;

                }

             

                /**

                 * @return the cellNumber

                 */

                public String getCellNumber() {

                    return cellNumber;

                }

             

                /**

                 * @param cellNumber

                 *            the cellNumber to set

                 */

                public void setCellNumber(String cellNumber) {

                    this.cellNumber = cellNumber;

                }

             

                /**

                 * @return the preferenceId

                 */

                public Integer getPreferenceId() {

                    return preferenceId;

                }

             

                /**

                 * @param preferenceId

                 *            the preferenceId to set

                 */

                public void setPreferenceId(Integer preferenceId) {

                    this.preferenceId = preferenceId;

                }

             

                /**

                 * @return the type

                 */

                public String getType() {

                    return type;

                }

             

                /**

                 * @param type

                 *            the type to set

                 */

                public void setType(String type) {

                    this.type = type;

                }

             

                /**

                 * @param deleted

                 *            the deleted to set

                 */

                public void setDeleted(boolean deleted) {

                    this.deleted = deleted;

                }

             

                /**

                 * @return the deleted

                 */

                public boolean isDeleted() {

                    return deleted;

                }

             

                /**

                 * @param customerCardEntity

                 *            the customerCardEntity to set

                 */

                public void setCustomerCardEntity(CustomerCardEntity customerCardEntity) {

                    this.customerCardEntity = customerCardEntity;

                }

             

                /**

                 * @return the customerCardEntity

                 */

                public CustomerCardEntity getCustomerCardEntity() {

                    return customerCardEntity;

                }

             

             

            }

            • 3. Re: Insertion happened when update the record
              Nicklas Karlsson Master

              Another thing to look into is mis-scoping of the entitymanger so that it forgets about the entity and inserts it as new

              1 of 1 people found this helpful
              • 4. Re: Insertion happened when update the record
                Stephen Coy Master

                You're not showing how you call UserMapper.mapUserEntity(...), but I think you will find that you actually need:

                1. mapNewUserEntity(...)
                2. mapExistingUserEntity(Integer userId, CLRPUser user)

                 

                as the logic for new vs existing entities will be substantially different.

                 

                Right now I guess you're getting new entities every time because you're creating them (using new) in mapUserEntity.

                 

                BTW, in my opinion you should never use the "save" word in conjunction with methods that perform database updates/insertions, because most of the time the "save" has not been performed when the method is complete. The database update will not be completed until the current transaction is committed.

                1 of 1 people found this helpful
                • 5. Re: Insertion happened when update the record
                  Mary Hansen Newbie

                  Niclas & Stephen

                   

                  Can you please help me, where I need to make changes.. Because I am newbie to seam and jsf..

                   

                  Thanks in advance..

                  Mary

                  • 6. Re: Insertion happened when update the record
                    Scott Marlow Master

                    Mary,

                     

                    Have you enabled TRACE logging yet?  JPAReferenceGuide-Troubleshooting will help guide you in enabling TRACE logging for org.jboss.as.jpa.  Also, enable TRACE logging for org.hibernate.SQL.  The application server console will contain the trace output, that should include the SQL statements being executed (as well as the JPA EntityManager invocations that caused them).  That should give you a better idea of what your application code is doing.

                     

                    If you know an entities primary key, you can use EntityManager.find() to locate it.  If you don't know the primary key, there are other ways to look it up (e.g. EntityManager.createQuery(String) which part of your code seems to be using).  As others pointed out, creating a new instance of the entity, when you want to instead load from the database, is important.  I think you will likely have an easier time at this, once you have TRACE logging enabled.

                     

                    Scott

                    • 7. Re: Insertion happened when update the record
                      Mary Hansen Newbie

                      Scott,

                       

                      Thanks for your time..

                       

                      Hi debugged this scenario in my eclipse, in all cases the userId is passed well. till it went to JPAUserDao.java, after this my JPA code is :

                       

                      I just changed my userMapper to:

                       

                      public class UserMapper {

                          public static UserEntity mapUserEntity(CLRPUser user) {

                              UserEntity userEntity = new UserEntity();

                              userEntity.setUserId(user.getUserId());  //Note:-added this line

                              userEntity.setEmailAddress(user.getEmailAddress());

                              userEntity.setFirstName(user.getFirstName());

                              userEntity.setLastName(user.getLastName());

                              userEntity.setHomeNumber(user.getHomeNumber());

                               }

                      }

                       

                      Old Mapper:

                       

                      public class UserMapper {

                          public static UserEntity mapUserEntity(CLRPUser user) {

                              UserEntity userEntity = new UserEntity();

                               userEntity.setEmailAddress(user.getEmailAddress());

                              userEntity.setFirstName(user.getFirstName());

                              userEntity.setLastName(user.getLastName());

                              userEntity.setHomeNumber(user.getHomeNumber());

                           }

                      }

                       

                      My JPAcode is:


                      public Integer saveOrUpdate(UserEntity newUser) {


                      entityManager.merge(newUser);


                      return newUser.getUserId();

                                                                                                                  }

                       

                      Now the insertion is stopped and the page says the following exeption:

                      10:09:05,640 INFO  [STDOUT] Selected  userid ----- 4

                      10:09:05,640 INFO  [STDOUT] User Id getting is 4

                      10:09:05,640 INFO  [STDOUT] Hibernate: select userentity0_.userId as userId2_, userentity0_.LastUpdatedBy as LastUpda2_2_, userentity0_.LastUpdatedTime as LastUpda3_2_, userentity0_.UserId as UserId2_, userentity0_.ASPCustomerId as ASPCusto4_2_, userentity0_.EmailAddress as EmailAdd5_2_, userentity0_.FirstName as FirstName2_, userentity0_.LastName as LastName2_, userentity0_.OfficePhoneNumber as OfficePh8_2_, userentity0_.HomePhoneNumber as HomePhon9_2_, userentity0_.CellNumber as CellNumber2_, userentity0_.PreferenceId as Prefere11_2_, userentity0_.Type as Type2_, userentity0_.Deleted as Deleted2_ from User userentity0_ where userentity0_.userId=?

                      10:09:05,656 INFO  [STDOUT] Hibernate: select customerca0_.CustomerCardId as Customer1_7_0_, customerca0_.LastUpdatedBy as LastUpda2_7_0_, customerca0_.LastUpdatedTime as LastUpda3_7_0_, customerca0_.CustomerId as CustomerId7_0_, customerca0_.CardId as CardId7_0_, customerca0_.cardTypeId as cardTypeId7_0_, customerca0_.Action as Action7_0_, customerca0_.date as date7_0_, customerca0_.ASPCustomerId as ASPCusto8_7_0_ from CustomerCard customerca0_ where customerca0_.CustomerId=?

                      10:09:05,656 INFO  [STDOUT] Hibernate: select addresses0_.userId as userId2_, addresses0_.AddressId as AddressId2_, addressent1_.AddressId as AddressId3_0_, addressent1_.LastUpdatedBy as LastUpda2_3_0_, addressent1_.LastUpdatedTime as LastUpda3_3_0_, addressent1_.Address1 as Address4_3_0_, addressent1_.Address2 as Address5_3_0_, addressent1_.AddressType as AddressT6_3_0_, addressent1_.City as City3_0_, addressent1_.CountryId as CountryId3_0_, addressent1_.StateId as StateId3_0_, addressent1_.Zip as Zip3_0_, addressent1_1_.userId as userId4_0_, userentity2_.userId as userId2_1_, userentity2_.LastUpdatedBy as LastUpda2_2_1_, userentity2_.LastUpdatedTime as LastUpda3_2_1_, userentity2_.UserId as UserId2_1_, userentity2_.ASPCustomerId as ASPCusto4_2_1_, userentity2_.EmailAddress as EmailAdd5_2_1_, userentity2_.FirstName as FirstName2_1_, userentity2_.LastName as LastName2_1_, userentity2_.OfficePhoneNumber as OfficePh8_2_1_, userentity2_.HomePhoneNumber as HomePhon9_2_1_, userentity2_.CellNumber as CellNumber2_1_, userentity2_.PreferenceId as Prefere11_2_1_, userentity2_.Type as Type2_1_, userentity2_.Deleted as Deleted2_1_ from useraddress addresses0_ left outer join Address addressent1_ on addresses0_.AddressId=addressent1_.AddressId left outer join useraddress addressent1_1_ on addressent1_.AddressId=addressent1_1_.AddressId left outer join User userentity2_ on addressent1_1_.userId=userentity2_.userId where addresses0_.userId=?

                      10:09:05,656 INFO  [STDOUT] Hibernate: select customerca0_.CustomerCardId as Customer1_7_0_, customerca0_.LastUpdatedBy as LastUpda2_7_0_, customerca0_.LastUpdatedTime as LastUpda3_7_0_, customerca0_.CustomerId as CustomerId7_0_, customerca0_.CardId as CardId7_0_, customerca0_.cardTypeId as cardTypeId7_0_, customerca0_.Action as Action7_0_, customerca0_.date as date7_0_, customerca0_.ASPCustomerId as ASPCusto8_7_0_ from CustomerCard customerca0_ where customerca0_.CustomerId=?

                      10:09:10,437 INFO  [STDOUT] Hibernate: select userentity0_.userId as userId2_1_, userentity0_.LastUpdatedBy as LastUpda2_2_1_, userentity0_.LastUpdatedTime as LastUpda3_2_1_, userentity0_.UserId as UserId2_1_, userentity0_.ASPCustomerId as ASPCusto4_2_1_, userentity0_.EmailAddress as EmailAdd5_2_1_, userentity0_.FirstName as FirstName2_1_, userentity0_.LastName as LastName2_1_, userentity0_.OfficePhoneNumber as OfficePh8_2_1_, userentity0_.HomePhoneNumber as HomePhon9_2_1_, userentity0_.CellNumber as CellNumber2_1_, userentity0_.PreferenceId as Prefere11_2_1_, userentity0_.Type as Type2_1_, userentity0_.Deleted as Deleted2_1_, addresses1_.userId as userId3_, addressent2_.AddressId as AddressId3_, addressent2_.AddressId as AddressId3_0_, addressent2_.LastUpdatedBy as LastUpda2_3_0_, addressent2_.LastUpdatedTime as LastUpda3_3_0_, addressent2_.Address1 as Address4_3_0_, addressent2_.Address2 as Address5_3_0_, addressent2_.AddressType as AddressT6_3_0_, addressent2_.City as City3_0_, addressent2_.CountryId as CountryId3_0_, addressent2_.StateId as StateId3_0_, addressent2_.Zip as Zip3_0_, addressent2_1_.userId as userId4_0_ from User userentity0_ left outer join useraddress addresses1_ on userentity0_.userId=addresses1_.userId left outer join Address addressent2_ on addresses1_.AddressId=addressent2_.AddressId left outer join useraddress addressent2_1_ on addressent2_.AddressId=addressent2_1_.AddressId where userentity0_.userId=?

                      10:09:10,453 INFO  [STDOUT] Hibernate: select customerca0_.CustomerCardId as Customer1_7_0_, customerca0_.LastUpdatedBy as LastUpda2_7_0_, customerca0_.LastUpdatedTime as LastUpda3_7_0_, customerca0_.CustomerId as CustomerId7_0_, customerca0_.CardId as CardId7_0_, customerca0_.cardTypeId as cardTypeId7_0_, customerca0_.Action as Action7_0_, customerca0_.date as date7_0_, customerca0_.ASPCustomerId as ASPCusto8_7_0_ from CustomerCard customerca0_ where customerca0_.CustomerId=?

                      10:09:10,468 INFO  [STDOUT] Hibernate: insert into Address (LastUpdatedBy, LastUpdatedTime, Address1, Address2, AddressType, City, CountryId, StateId, Zip) values (?, ?, ?, ?, ?, ?, ?, ?, ?)

                      10:09:10,468 INFO  [STDOUT] Hibernate: insert into Address (LastUpdatedBy, LastUpdatedTime, Address1, Address2, AddressType, City, CountryId, StateId, Zip) values (?, ?, ?, ?, ?, ?, ?, ?, ?)

                      10:09:10,468 INFO  [STDOUT] User Id saved 4

                      10:09:10,484 INFO  [STDOUT] Hibernate: update User set LastUpdatedBy=?, LastUpdatedTime=?, UserId=?, ASPCustomerId=?, EmailAddress=?, FirstName=?, LastName=?, OfficePhoneNumber=?, HomePhoneNumber=?, CellNumber=?, PreferenceId=?, Type=?, Deleted=? where userId=?

                      10:09:10,515 WARN  [JDBCExceptionReporter] SQL Error: 1048, SQLState: 23000

                      10:09:10,515 ERROR [JDBCExceptionReporter] Column 'UserID' cannot be null

                      10:09:10,515 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session

                      org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

                          at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)

                          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)

                          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)

                          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

                          at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

                          at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)

                          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)

                          at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)

                          at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)

                          at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)

                          at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)

                          at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:612)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)

                          at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:344)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:244)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:195)

                          at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)

                          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)

                          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)

                          at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

                          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

                          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)

                          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)

                          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

                          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

                          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

                          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

                          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

                          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

                          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

                          at java.lang.Thread.run(Thread.java:619)

                      Caused by: java.sql.BatchUpdateException: Column 'UserID' cannot be null

                          at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)

                          at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)

                          at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:774)

                          at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)

                          ... 60 more

                      10:09:10,515 WARN  [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@11d5c7d

                      javax.persistence.EntityExistsException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

                          at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:604)

                          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524)

                          at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)

                          at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)

                          at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)

                          at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)

                          at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:612)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)

                          at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:344)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:244)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:195)

                          at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)

                          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)

                          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)

                          at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

                          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

                          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)

                          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)

                          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

                          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

                          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

                          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

                          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

                          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

                          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

                          at java.lang.Thread.run(Thread.java:619)

                      Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

                          at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)

                          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)

                          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)

                          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

                          at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

                          at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)

                          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)

                          ... 53 more

                      Caused by: java.sql.BatchUpdateException: Column 'UserID' cannot be null

                          at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)

                          at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)

                          at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:774)

                          at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)

                          ... 60 more

                      10:09:10,593 WARN  [SeamPhaseListener] uncaught exception, passing to exception handler

                      java.lang.IllegalStateException: Could not commit transaction

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:624)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)

                          at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:344)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:244)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:195)

                          at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)

                          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)

                          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)

                          at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

                          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

                          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)

                          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)

                          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

                          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

                          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

                          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

                          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

                          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

                          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

                          at java.lang.Thread.run(Thread.java:619)

                      Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1401)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)

                          at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)

                          at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)

                          at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:612)

                          ... 43 more

                      Caused by: javax.persistence.EntityExistsException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

                          at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:604)

                          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524)

                          at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)

                          at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)

                          ... 48 more

                      Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

                          at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)

                          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)

                          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)

                          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

                          at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

                          at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)

                          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)

                          ... 53 more

                      Caused by: java.sql.BatchUpdateException: Column 'UserID' cannot be null

                          at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)

                          at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)

                          at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:774)

                          at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)

                          ... 60 more

                      10:09:10,609 ERROR [Exceptions] handled and logged exception

                      java.lang.IllegalStateException: Could not commit transaction

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:624)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)

                          at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:344)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:244)

                          at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:195)

                          at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)

                          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)

                          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)

                          at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)

                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                          at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

                          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

                          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)

                          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)

                          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

                          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

                          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

                          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

                          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

                          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

                          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

                          at java.lang.Thread.run(Thread.java:619)

                      Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1401)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)

                          at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)

                          at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)

                          at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)

                          at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:612)

                          ... 43 more

                      Caused by: javax.persistence.EntityExistsException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

                          at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:604)

                          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524)

                          at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)

                          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)

                          at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)

                          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)

                          ... 48 more

                      Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

                          at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)

                          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)

                          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)

                          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)

                          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

                          at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

                          at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)

                          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)

                          ... 53 more

                      Caused by: java.sql.BatchUpdateException: Column 'UserID' cannot be null

                          at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2018)

                          at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)

                          at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:774)

                          at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

                          at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)

                          ... 60 more

                      10:09:11,156 INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.

                      sourceId=null[severity=(WARN 1), summary=(Duplicate record), detail=(Duplicate record)]

                       

                      Looking for assistance indeed in this, lost my mind in this for long..

                       

                      Thansk in advance

                      Mary

                      • 8. Re: Insertion happened when update the record
                        Stephen Coy Master

                        If your UserEntity already has a corresponding record in the database then you must load it first using EntityManager.find(userId) as suggested by Scott Marlow above.

                         

                        You can't just create a new one and stuff the userId in it. Your UserEntity has other associated entities (CustomerCardEntity and AddressEntity) so you need to be careful with your mapping function. Which is why I suggested two different methods should be used. Normally you can tell from the context whether or not a new record has just been created.