Entity Bean-3 Delete
package mypack;
import java.util.Scanner;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
public class Delete {
public static void main(String[] args) {
EntityManagerFactory f=GetEntity.getManagerFactory();
EntityManager em=GetEntity.getEntityManager();
Scanner in=new Scanner(System.in);
System.out.println("Enter emp id...");
int id=in.nextInt();
EntityTransaction t=em.getTransaction();
t.begin();
Emp e=em.find(Emp.class, id);
em.remove(e);
t.commit();
em.close();
System.out.println("deleted successfully...");
}
}