I have implemented an active flag on certain domain objects which can be turned "off" from the web side. When they are deactivated, this means that any access to them should be denied EXCEPT when I explicitly ask for inactive objects; any object that is linked to that domain object should only get active objects (e.g. object a has a collection of object b and obj b can be toggled active/inactive, so object a should automatically only get active b's).
I was wondering how people are implementing this. I have added a "where" class attribute to the object's mapping and this works, but there is no way in Hibernate, aside from using a native SQL query, to retrieve the inactive objects (if, for example, the object needs to be re-activated). Is there a better way to do this? I have looked at filters, but they don't seem to accomplish what I need either because you cannot turn them on all the time. So is the native SQL the best way to go?
Thanks for any help or insight,
Rexxe
Hibernate version: 3.0.5
Mapping documents:
Code:
<class name="foo.Company" where="active">
Code:
<property name="active" type="java.lang.Boolean" update="true"
insert="true" column="active" not-null="true" />