1

Can anyone tell me how to perform 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();
2
  • 1
    Any particular reason you're not using EntityManager? Commented Dec 2, 2010 at 4:26
  • 1
    are you getting any error messages? Or does it just not do anything? Commented Dec 2, 2010 at 4:28

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.