Hibernate Insert Query in Java
Can anyone tell me how to perfor开发者_C百科m an insert query with Hibernate and back end postgresql I am using the following implementation but not working
Session session = gileadHibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
User A= new User();
A.setId(67);
A.setFirstName("Noor");
A.setLastName("asd");
A.setMobileNumber("2435");
A.setTelephoneNumber("dfg");
session.save(A);
session.getTransaction().commit();
As Matt Ball suggested, try using EntityManager.persist(java.lang.Object entity)
(see here) instead. Or simply try using persist without EntityManager (see this discussion).
精彩评论