开发者

Hibernate Insert Query in Java

开发者 https://www.devze.com 2023-01-28 03:13 出处:网络
Can anyone tell me how to perfor开发者_C百科m an insert query with Hibernate and back end postgresql

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消