How to persist an Array List of type Entity in JPA ?
For example, there is an entity called "Table".
I am creating an array list ArrayList<Table> table = new ArrayList<Table>();
Trying to persist it using entityManager.persist(table);
and it did not work. Any solution for this ?
EntityManagerFactory emf = Persistence.createEntityManagerFactory("TDEMSPU");
em = emf.createEntityManager();
em.getTransaction().begin();
List<Enquiry> tempEnqList = tempEnqList();
for (Iterator<Enquiry> it = tempEnqList.iterator(); it.hasNext();) {
Enquiry enquiry = it.next();
em.persist(enquiry);
em.flush();
em.clear();
}
em.getTransaction().commit();