You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Tino Schöllhorn <t....@plattform-gmbh.de> on 2006/03/26 11:59:58 UTC

Way to prevent store?

Hi,

I have a situation where I want to prevent the creation of an object in 
the database. Is there a way to prevent the insertion via the 
callback-methods (beforeInsert....) ? Throwing an Exception in these 
methods doesn't work, because the situation is not an error and I want 
to prevent the change of client code.

If that is not possible should I extend the PersistenceBrokerImpl and 
change the
PB.store(Object,Identity,ClassDescriptor, boolean, boolean) method 
accordingly?

I am glad for any


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Way to prevent store?

Posted by Armin Waibel <ar...@apache.org>.
Hi Tino,

Tino Schöllhorn wrote:
> Hi,
> 
> I have a situation where I want to prevent the creation of an object in 
> the database. Is there a way to prevent the insertion via the 
> callback-methods (beforeInsert....) ? Throwing an Exception in these 
> methods doesn't work, because the situation is not an error and I want 
> to prevent the change of client code.

Could you describe more detailed the situation? If you don't want to 
create an object why do you call PB.store(...)?

> 
> If that is not possible should I extend the PersistenceBrokerImpl and 
> change the
> PB.store(Object,Identity,ClassDescriptor, boolean, boolean) method 
> accordingly?
> 

This will be possible. You can introduce a custom-attribute "readonly" 
and declare it in the class-descriptor.
<attribute attribute-name="readonly" attribute-value="true"/>
file:///E:/dev/db-ojb-1b/ojb/doc/docu/guides/repository.html#custom+attribute

In PB.store you can check the custom-attribute with:
String result = cld.getAttribute("readonly");

regards,
Armin

> I am glad for any
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org