JBoss Community

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

created by Icey Thomas in EJB Development - View the full discussion

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!

Reply to this message by going to Community

Start a new discussion in EJB Development at Community