|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface UniqueTreeConstraint<N extends TreeNode>
Implementers check unique constraints in a tree-table. This interface expects the constructor of the implementation to receive names of properties that have to be unique.
Mind that this constraint implementation must be applied BEFORE setXxx() is called on a domain object (POJO), as the JPA container might flush the setXxx() call to database before the checker query is launched (then, of course, the wrong value will be found by the query). Thus the application MUST calltreeDao.checkUniqueConstraint()
BEFORE updating an unique property,
and it must do this using a clone of the persistent entity.
See AbstractTreeTest.setName()
unit test method for an example how to do this.
Method Summary | |
---|---|
boolean |
checkUniqueConstraint(java.util.List<N> candidates,
TreeActionLocation<N> location)
The implementation of this is expected to check the uniqueness of passed node(s). |
void |
setContext(DbSession session,
TreeDao<N> dao,
java.lang.String nodeEntityName,
java.lang.String pathEntityName)
Called by the DAO to publish context information to this constraint-checker. |
Method Detail |
---|
boolean checkUniqueConstraint(java.util.List<N> candidates, TreeActionLocation<N> location)
treeDao.checkUniqueConstraint()
explicitly when updating a node property, see explanation in header comment!
candidates
- one (default) or more (copy/move only) entities that hold values
to check for uniqueness at location, when list, the copied node will be first,
then its sub-nodes.location
- the information where the pending modification is going to happen.
void setContext(DbSession session, TreeDao<N> dao, java.lang.String nodeEntityName, java.lang.String pathEntityName)
dao
- the calling DAO, provides tree access for reading children, parents, etc.nodeEntityName
- name of the JPQL node database table.pathEntityName
- optionally the name of the JPQL tree-path database table, can be null, this is for ClosureTable only.session
- the database session to use for uniqueness checks.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |