I use Hibernate with annotations. I need to insert object into the database using a method who needs one parameter that I need to calculate, to do this I use:
SQLQuery sqlQuery = getSession().createSQLQuery(queryString);
sqlQuery.executeUpdate();
The queryString contains:
INSERT INTO TABLE(ID, NUMBER) VALUES (SEC_TABLE.NEXTVAL, 549)
The object is inserted into the database, but when I try to get the id, I get a null value.
What can I do?
When I use getHibernateTemplate().update(obj);
I have not problems getting the id, but I need to customize the sql insert.
Thanks