-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Execute "SET ROLE XXXX identified by XXXX"
PostPosted: Mon Feb 17, 2014 1:59 pm 
Newbie

Joined: Mon Feb 17, 2014 1:56 pm
Posts: 1
'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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.