|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.anasoft.os.daofusion.criteria.AssociationPathRegister
public class AssociationPathRegister
Register of AssociationPath
instances and corresponding
Hibernate Criteria
to be reused when modifying the root
Criteria
instance.
This class is used by NestedPropertyCriteria
to initialize
CriteriaImpl.Subcriteria
mappings in a safe way, avoiding the
duplicate association path Hibernate Criteria API issue.
AssociationPathRegister
is a thin wrapper around the given
Criteria
instance that gets initialized with existing
CriteriaImpl.Subcriteria
mappings at construction time. It is therefore
safe to create multiple AssociationPathRegister
instances
operating on the same Criteria
.
You can use this class to modify Criteria
instances in a safe
way on your own as well (always prefer get(AssociationPath)
in
favor of calling the createCriteria
method directly).
AssociationPath
,
NestedPropertyCriteria
Constructor Summary | |
---|---|
AssociationPathRegister(org.hibernate.Criteria rootCriteria)
Creates a new association path register, rooted at the given Criteria instance. |
Method Summary | |
---|---|
org.hibernate.Criteria |
get(AssociationPath associationPath)
Returns a Criteria instance for the given
AssociationPath . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AssociationPathRegister(org.hibernate.Criteria rootCriteria)
Criteria
instance.
Note that the register is initialized with Hibernate
Criteria
mappings according to the current
state of rootCriteria.
rootCriteria
- Root Criteria
instance.Method Detail |
---|
public org.hibernate.Criteria get(AssociationPath associationPath)
Criteria
instance for the given
AssociationPath
.
This method ensures that Hibernate Criteria
mappings are lazily initialized (with existing criteria
instances being reused) prior to returning the target
Criteria
.
Resulting Criteria
instances have unique aliases
(based on their association paths) so that they can be
referenced in complex Hibernate queries like this:
Criteria criteria1 = apRegister.get(associationPath1); String alias1 = criteria1.getAlias(); Criteria criteria2 = apRegister.get(associationPath2); String alias2 = criteria2.getAlias(); rootCriteria.add( Restrictions.or( Restrictions.eq(alias1 + "." + targetPropertyName1, value1), Restrictions.eq(alias2 + "." + targetPropertyName2, value2) ));You can safely call this method multiple times with same association path argument. Note that unused association path criteria instances might break your query behavior when using certain join types (e.g.
inner join
).
associationPath
- Association path for which
to obtain the Criteria
instance.
Criteria
instance for the given
AssociationPath
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |