private void createAssociationPathCriteriaMap() { final Iterator<CriteriaImpl.Subcriteria> iter = rootCriteria.iterateSubcriteria(); while ( iter.hasNext() ) { CriteriaImpl.Subcriteria crit = iter.next(); String wholeAssociationPath = getWholeAssociationPath( crit ); Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit ); if ( old != null ) { throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } JoinType joinType = crit.getJoinType(); old = associationPathJoinTypesMap.put( wholeAssociationPath, joinType ); if ( old != null ) { // TODO : not so sure this is needed... throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } if ( crit.getWithClause() != null ) { this.withClauseMap.put( wholeAssociationPath, crit.getWithClause() ); } } }
while ( subcriteriaIterator.hasNext() ) { final CriteriaImpl.Subcriteria subcriteria = subcriteriaIterator.next(); final LockMode lm = subcriteria.getLockMode(); if ( lm != null ) { lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lm ); if ( subcriteria.getWithClause() != null ) { final TypedValue[] tv = subcriteria.getWithClause().getTypedValues( subcriteria, this ); for ( TypedValue aTv : tv ) { values.add( aTv.getValue() );
while ( iter.hasNext() ) { CriteriaImpl.Subcriteria subcriteria = ( CriteriaImpl.Subcriteria ) iter.next(); LockMode lm = subcriteria.getLockMode(); if ( lm != null ) { lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lm ); if ( subcriteria.getWithClause() != null ) TypedValue[] tv = subcriteria.getWithClause().getTypedValues( subcriteria, this ); for ( int i = 0; i < tv.length; i++ ) { values.add( tv[i].getValue() );
while ( iter.hasNext() ) { CriteriaImpl.Subcriteria subcriteria = ( CriteriaImpl.Subcriteria ) iter.next(); LockMode lm = subcriteria.getLockMode(); if ( lm != null ) { lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lm ); if ( subcriteria.getWithClause() != null ) TypedValue[] tv = subcriteria.getWithClause().getTypedValues( subcriteria, this ); for ( int i = 0; i < tv.length; i++ ) { values.add( tv[i].getValue() );
} else { CriteriaImpl.Subcriteria subcriteria = (CriteriaImpl.Subcriteria) criteria; c = (CriteriaImpl) subcriteria.getParent();
public Boolean checkForAlias(Criteria criteria, String alias) { Field f = null; try { f = criteria.getClass().getDeclaredField("subcriteriaList"); f.setAccessible(true); List<CriteriaImpl.Subcriteria> subCriteria = (List<CriteriaImpl.Subcriteria>) f.get( criteria); if (subCriteria.size() == 0) { return false; } for (CriteriaImpl.Subcriteria subCrit : subCriteria) { if (subCrit.getAlias().contains(alias)) { return true; } } } catch (NoSuchFieldException e) { throw new RuntimeException("Failed to create alias", e); } catch (IllegalAccessException e) { throw new RuntimeException("Failed to create alias", e); } return false; }
/** * Add a alias for the specified property to the criteria. * * @param property * the property * @return the alias */ protected String addAlias(String property) { Iterator<Subcriteria> subcriteria = ((CriteriaImpl) this.criteria).iterateSubcriteria(); while (subcriteria.hasNext()) { Subcriteria sc = subcriteria.next(); if (sc.getPath() .equals(property)) { return sc.getAlias(); } } String alias = "odf_" + property; if (!this.aliases.contains(alias)) { this.criteria.createAlias(property, alias); this.aliases.add(alias); } return alias; }
private void createAssociationPathCriteriaMap() { Iterator iter = rootCriteria.iterateSubcriteria(); while ( iter.hasNext() ) { CriteriaImpl.Subcriteria crit = ( CriteriaImpl.Subcriteria ) iter.next(); String wholeAssociationPath = getWholeAssociationPath( crit ); Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit ); if ( old != null ) { throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } JoinType joinType = crit.getJoinType(); old = associationPathJoinTypesMap.put( wholeAssociationPath, joinType ); if ( old != null ) { // TODO : not so sure this is needed... throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } if ( crit.getWithClause() != null ) { this.withClauseMap.put(wholeAssociationPath, crit.getWithClause()); } } }
Disjunction d = Restrictions.disjunction(); ... // d is set up here Criteria linkedEntitySubcriteria = null; try { List<CriteriaImpl.Subcriteria> subcriteriaList = (ArrayList) FieldUtils.readField(criteria, "subcriteriaList", true); for (CriteriaImpl.Subcriteria subcriteria : subcriteriaList) { if (subcriteria.getPath().equals(linkedEntityVariable)) { linkedEntitySubcriteria = subcriteria; break; } } } catch (IllegalArgumentException | IllegalAccessException e) { System.out.println("Can't get subcriteria"); } if (linkedEntitySubcriteria == null) { linkedEntitySubcriteria = criteria.createCriteria(linkedEntityVariable); } linkedEntitySubcriteria.add(d);
private void createAssociationPathCriteriaMap() { Iterator iter = rootCriteria.iterateSubcriteria(); while ( iter.hasNext() ) { CriteriaImpl.Subcriteria crit = ( CriteriaImpl.Subcriteria ) iter.next(); String wholeAssociationPath = getWholeAssociationPath( crit ); Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit ); if ( old != null ) { throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } JoinType joinType = crit.getJoinType(); old = associationPathJoinTypesMap.put( wholeAssociationPath, joinType ); if ( old != null ) { // TODO : not so sure this is needed... throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } if ( crit.getWithClause() != null ) { this.withClauseMap.put(wholeAssociationPath, crit.getWithClause()); } } }
CriteriaQueryTranslator#createAssociationPathCriteriaMap() private void createAssociationPathCriteriaMap() { Iterator iter = rootCriteria.iterateSubcriteria(); while ( iter.hasNext() ) { CriteriaImpl.Subcriteria crit = ( CriteriaImpl.Subcriteria ) iter.next(); String wholeAssociationPath = getWholeAssociationPath( crit ); Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit ); if ( old != null ) { throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } int joinType = crit.getJoinType(); old = associationPathJoinTypesMap.put( wholeAssociationPath, new Integer( joinType ) ); if ( old != null ) { // TODO : not so sure this is needed... throw new QueryException( "duplicate association path: " + wholeAssociationPath ); } } }
public Criteria createCriteria(String associationPath) { return createCriteria( associationPath, JoinType.INNER_JOIN ); }
public Criteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException { return new Subcriteria( this, associationPath, alias, joinType, withClause ); }
public Criteria createCriteria(String associationPath, String alias, JoinType joinType) { return new Subcriteria( this, associationPath, alias, joinType ); }
public Criteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException { return new Subcriteria( this, associationPath, alias, joinType, withClause ); }
public Criteria createCriteria(String associationPath, String alias, JoinType joinType) throws HibernateException { return new Subcriteria( Subcriteria.this, associationPath, alias, joinType ); }
public Criteria createCriteria(String associationPath, JoinType joinType) throws HibernateException { return new Subcriteria( Subcriteria.this, associationPath, joinType ); }