简体   繁体   中英

Execute Insert and Select queries simultaneously from Hibernate

I have the following pl/sql query,

INSERT INTO Table(ID,..................) 
VALUES(SEQ.nextval,....................); 
SELECT SEQ.currval ID FROM DUAL;

I need to get ID using hibernate. I am using the following query which showing error,

.....getDataSession().createSQLQuery(hQuery).list()

Any one help me.

Create new Object and save it using session.save() method it will return this object id.

 Object object = new Object();
    //add object properties 
    object.setXXX(value);
    //now save the object   
    String id =(String)getDataSession().save(object);

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM