I'm developing an application using spring 4.0.6 and Hibernate 4.2.21. I have an entity as follow:
public class A {
@OneToMany(mappedBy="parent", fetch = FetchType.LAZY)
private Set<A> children = new HashSet<A>(0);
@ManyToOne(fetch = FetchType.EAGER)
private A parent;
/*
*
* Getters And Setters
*/
}
In another words, A
entity is a tree. Now I want to secure all nodes of tree. Consider the following tree:
Node-1
Node-1.1
Node-1.1.1
Node-1.1.2
Node-1.2
Node-1.3
Node-2
Node-3
Node-3.1
Node-3.2
Node-3.3
I secure node as follow:
@PostFilter("hasPermission(filterObject, 'read')")
public List<A> getAll() {}
This code secure nodes in first level(Node-1
, Node-2
& Node-3
). Now we want to get a user read
acccess in Node-1
, Node-1.1
& Node-1-2
nodes. How do we implement it?