'm developing a web app (java) and I'm using Hibernate 4.1.4 and oracle 11g.
By security's rules in Database, the dbuser (the db user that app uses) doesnt have insert privileges by default. Then every time my app is gonna do a insert, it must execute the query "SET ROLE XXXX ...." before the insertion-query (or update) be executed. This "set role.." will give to dbuser the privileges to insert into some tables in that transaction. How to do it with Hibernate?
I tried do it on my save method:
Code:
public Object saveOrUpdate(Object entity) {
Query query = getSessionFactory().getCurrentSession().createSQLQuery("set role XXXX identified by XXXX");
query.executeUpdate();
getSessionFactory().getCurrentSession().saveOrUpdate(entity);
return entity;
}
but it doesnt work. I get the error "view or table not exist". When I try execute only the query.executeUpdate() or the saveOrUpdate(entity) no error happened.
I guess it is all. If you need more details, please ask to me. Thanks!