0 Replies Latest reply on Oct 28, 2011 1:01 AM by icey.xiong

    static class act as an entity ,EntityNotFoundException happend when delete the last record

    icey.xiong

      Dear all,

           I write an entity like this:

      @Entity 
      public class Employee 
      {
           @Id
           private long id;     
           private String name;
      
           @OneToMany
           private Mao<String,EmpDetail> detail=new TreeMap<String,EmpDetail>();
      
           //set ,get functions pass
      
           @Entity
           public static class EmpDetail
           {
                    @Id
                     protected long id;
                     protected String address;
                     //set ,get functions pass
           }
      }
      I  delete an EmpDetail like this:
      

          em.remove(em.getReference(EmpDetail.class,4)); // em is the entity manager

        I delete the record successful but the last one.

      Exception is here:   javax.persistence.EntityNotFoundException:deleted entity passed to persiste:(...Employee$EmpDetail#<null>)

       

      some one knows what is going on?  thank you!