Hello,
I have grails application with hibernate filter, that determine access rights to table rows. It works fine on select, but now I want to control update. I've added PreUpdateEventListener that looks like:
Code:
......
public static final int METHOD_READ= 1
public static final int METHOD_UPDATE= 2
......
public boolean onPreUpdate(PreUpdateEvent event) {
// control only need classes
if (!needClassNames.contains(event.entity.class.name))
return false;
Session session = ....//get current session
Filter filter = session.getEnabledFilter(getFilterName(event.entity.class.name))
filter.setParameter('method', METHOD_UPDATE)
ArrayList list = Book.executeQuery("select s.id from "+event.entity.class.name+" s where s.id = ?)", [event.entity.id])
//Book is a some domain class, not equals to event.entity.class
//will be added filter code and if current user hasn't permission to 'method' METHOD_UPDATE sql query will return zero values
return (list == null || list.size() == 0)
}
while executing Book.executeQuery it call onPreUpdate again, goes to this line and so on. finally it crash with stack overflow exception by this infinite self calling. can anybody help me?