1 Reply Latest reply on Feb 3, 2008 12:58 AM by xiaocheng yuan

    why commit twice?

    xiaocheng yuan Newbie

      when i create a object using id whick is already in database when i press the create button i check if it exists,but i got my message age,why

       try {
      
       Kokyaku k = (Kokyaku) getEntityManager().createQuery(
       "select k from Kokyaku k where k.kokyakuCd = :id")
       .setParameter("id", this.instance.getKokyakuCd())
       .getSingleResult();
       if (k != null) {
       FacesMessages.instance().add(
       "kokyaku " + this.instance.getKokyakuCd() + "already exist");
       isSuccess = false;
       }
      
       } catch (NoResultException ex) {
       }
      
      

      i see in other posts it seems there is something like tx1,tx2,but i can't find anything about this transaction behaviour in reference.
      anyone helps me

        • 1. Re: why commit twice?
          xiaocheng yuan Newbie

          what shows me in pages is

          kokyaku 11already exist kokyaku 11already exist

          and i retrieve my message like this
           <h:messages globalOnly="true" styleClass="message" id="globalMessages"
           showDetail="true" layout="table" />
          

          also in console

          14:54:38,546 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
          sourceId=kokyaku:kokyakuCdDecoration:kokyakuCdCreate[severity=(ERROR 2), summary=(値ã�¯å¿…é ˆã�§ã�™), detail=(値ã�¯å¿…é ˆã�§ã�™)]
          14:54:54,671 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
          sourceId=kokyaku:kokyakuCdDecoration:kokyakuCdCreate[severity=(ERROR 2), summary=(値ã�¯å¿…é ˆã�§ã�™), detail=(値ã�¯å¿…é ˆã�§ã�™)]