-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to enable read-only access to an object?
PostPosted: Fri Jul 01, 2005 12:36 am 
I would like to prevent users from saving class instances to the database. To do so, I've tried combinations of mapping the class as immutable and using a read-only cache. All tests result in preventing UPDATE and DELETE operations, but not INSERT.

I could map a non-nullable column as read only (update="false" insert="false"), but the exception returned to the user is misleading. Furthermore, the solution is not bulletproof since someone can change the database schema.

Is there a clean way to specify such behavior in nHibernate? Ideally, I would like to specify an attribute at the class level, but haven't found such an attribute in the documentation.


Top
  
 
 Post subject:
PostPosted: Sat Jul 02, 2005 12:04 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
At which level are you working ?

The dumb answer would be "don't give to your users the UI to do Insert/Update/Delete" :arrow:

If you are at a lower level (like providing an interface to UI developers) then:
1- They should be aware that this entities are "immutable"
2- You can throw exception when trying to Save/Update/Delete an immutable entity :D

But if you still want NHibernate to manage that for you, then catch the "exception returned to the user that is misleading" and throw another...

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 2:49 am 
Newbie

Joined: Wed Jun 29, 2005 3:32 am
Posts: 2
Perhaps,you try it
Code:
access="nosetter.pascalcase-m-underscore"
In your entity class those read_only property have a getter and not setter.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 12:56 pm 
KPixel wrote:
At which level are you working ?

The dumb answer would be "don't give to your users the UI to do Insert/Update/Delete" :arrow:

If you are at a lower level (like providing an interface to UI developers) then:
2- You can throw exception when trying to Save/Update/Delete an immutable entity :D


Thanks for the advice, KPixel. I ended up implementing this policy for the time being and it works well.


Top
  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 12:57 pm 
gpciom126 wrote:
Perhaps,you try it
Code:
access="nosetter.pascalcase-m-underscore"
In your entity class those read_only property have a getter and not setter.


Looks interesting! I'll give it a try. Thanks!


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.