-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping column priveleges
PostPosted: Sat Dec 19, 2009 4:53 am 
Beginner
Beginner

Joined: Mon Dec 14, 2009 12:26 am
Posts: 23
Hi folks

I have an existing PostgreSQL 8.4 database I'm connecting to via Hibernate (using JPA2 Annotation-based mappings). The DB uses column priveleges to control what different user roles are allowed to do. Hibernate connects as the application user, so it is subject to those permissions checks.

My problem is that I don't know how to map columns where the column may or may not be insertable / updatable depending on the priveleges of the user whose credentials were used to create the SessionFactory.

Is there any way to change the `updatable' and `insertable' (JPA2) attributes of an entity mapping at runtime? Or some other smarter way to handle this?

I know I could build a fully dynamic XML mapping if I was using Hibernate directly (https://www.hibernate.org/171.html) but is there any less drastic middle ground availabile?

Has anyone tried using @Persister to extend org.hibernate.persister.EntityPersister for column-permission awareness, for example?


Top
 Profile  
 
 Post subject: Re: Mapping column priveleges
PostPosted: Sat Dec 19, 2009 11:33 pm 
Beginner
Beginner

Joined: Mon Dec 14, 2009 12:26 am
Posts: 23
Possible answer-to-self:

There doesn't seem to be any JPA-standard way to achieve this.

The Hibernate Annotations docs has a chapter "Overriding metadata through XML" that looks promising. It looks like it should be possible to build such XML overrides dynamically and feed them to the persistence unit during creation by pointing to the overrides as
Code:
hibernate.ejb.cfgfile
in the passed properties map.

The programmatic
Code:
Ejb3Configuration
class may provide an alternative, too.


Top
 Profile  
 
 Post subject: Re: Mapping column priveleges
PostPosted: Tue Jan 05, 2010 10:06 pm 
Beginner
Beginner

Joined: Mon Dec 14, 2009 12:26 am
Posts: 23
See follow-on: https://forum.hibernate.org/viewtopic.php?f=1&t=1001854&p=2423111#p2423111


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

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.