Package org.hibernate.engine.query.sql

Examples of org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn


        }
      };
    }

    public NativeSQLQueryReturn buildReturn() {
      return new NativeSQLQueryJoinReturn( alias, ownerTableAlias, joinedPropertyName, propertyMappings, lockMode );
    }
View Full Code Here


    if ( loc < 0 ) {
      throw new QueryException( "not a property path: " + path );
    }
    String ownerAlias = path.substring(0, loc);
    String role = path.substring(loc+1);
    queryReturns.add( new NativeSQLQueryJoinReturn(alias, ownerAlias, role, CollectionHelper.EMPTY_MAP, lockMode) );
    return this;
  }
View Full Code Here

        }
      };
    }

    public NativeSQLQueryReturn buildReturn() {
      return new NativeSQLQueryJoinReturn( alias, ownerTableAlias, joinedPropertyName, propertyMappings, lockMode );
    }
View Full Code Here

    check( true, aliasEntityNameLockMode, new NativeSQLQueryRootReturn( "abc", "Person", LockMode.NONE ) );
    check( true, aliasEntityNameDiffLockMode, new NativeSQLQueryRootReturn( "abc", "Person", LockMode.OPTIMISTIC ) );
  }

  public void testNativeSQLQueryJoinReturn() {
    NativeSQLQueryJoinReturn r1 = new NativeSQLQueryJoinReturn( "a", "b", "c", null, null);
    NativeSQLQueryJoinReturn r2 = new NativeSQLQueryJoinReturn( "a", "c", "b", null, null);
    NativeSQLQueryJoinReturn r3NullMap = new NativeSQLQueryJoinReturn( "b", "c", "a", null, null);
    NativeSQLQueryJoinReturn r3EmptyMap= new NativeSQLQueryJoinReturn( "b", "c", "a", new HashMap(), null);
    NativeSQLQueryJoinReturn r4 = new NativeSQLQueryJoinReturn( "b", "c", "a", Collections.singletonMap( "key", "value" ), null);
    NativeSQLQueryJoinReturn r5 = new NativeSQLQueryJoinReturn( "b", "c", "a", Collections.singletonMap( "otherkey", "othervalue" ), null);
    NativeSQLQueryJoinReturn r6 = new NativeSQLQueryJoinReturn( "b", "c", "a", Collections.singletonMap( "key", "value" ), LockMode.NONE );
    NativeSQLQueryJoinReturn r7 = new NativeSQLQueryJoinReturn( "b", "c", "a", null, LockMode.NONE );

    check( false, r1, r2 );
    check( false, r1, r3NullMap );
    check( false, r1, r3EmptyMap );
    check( false, r1, r4 );
    check( false, r1, r5 );
    check( false, r1, r6 );
    check( false, r1, r7 );

    check( false, r2, r3NullMap );
    check( false, r2, r3EmptyMap );
    check( false, r2, r4 );
    check( false, r2, r5 );
    check( false, r2, r6 );
    check( false, r2, r7 );

    check( true, r3NullMap, r3EmptyMap );
    check( false, r3NullMap, r4 );
    check( false, r3NullMap, r5 );
    check( false, r3NullMap, r6 );
    check( false, r3NullMap, r7 );

    check( false, r3EmptyMap, r4 );
    check( false, r3EmptyMap, r5 );
    check( false, r3EmptyMap, r6 );
    check( false, r3EmptyMap, r7 );

    check( false, r4, r5 );
    check( false, r4, r6 );
    check( false, r4, r7 );

    check( false, r5, r6 );
    check( false, r5, r7 );

    check( false, r6, r7 );

    check( true, r1, new NativeSQLQueryJoinReturn( "a", "b", "c", null, null) );
    check( true, r2, new NativeSQLQueryJoinReturn( "a", "c", "b", null, null) );
    check( true, r3NullMap, new NativeSQLQueryJoinReturn( "b", "c", "a", null, null) );
    check( true, r3EmptyMap, new NativeSQLQueryJoinReturn( "b", "c", "a", new HashMap(), null) );
    check( true, r4, new NativeSQLQueryJoinReturn( "b", "c", "a", Collections.singletonMap( "key", "value" ), null) );
    check( true, r5, new NativeSQLQueryJoinReturn( "b", "c", "a", Collections.singletonMap( "otherkey", "othervalue" ), null) );
    check( true, r6, new NativeSQLQueryJoinReturn( "b", "c", "a", Collections.singletonMap( "key", "value" ), LockMode.NONE ) );
    check( true, r7, new NativeSQLQueryJoinReturn( "b", "c", "a", null, LockMode.NONE ) );
  }
View Full Code Here

  }

  public void testNativeSQLQueryReturnTypes() {
    NativeSQLQueryScalarReturn r1 = new NativeSQLQueryScalarReturn( "a", sfi().getTypeResolver().basic( "int" ) );
    NativeSQLQueryRootReturn r2 = new NativeSQLQueryRootReturn( "a", "b", LockMode.NONE );
    NativeSQLQueryJoinReturn r3 = new NativeSQLQueryJoinReturn( "a", "b", "c", Collections.singletonMap( "key", "value" ), LockMode.NONE );
    NativeSQLQueryCollectionReturn r4 = new NativeSQLQueryCollectionReturn( "a", "b", "c", Collections.singletonMap( "key", "value" ), LockMode.NONE);

    check( false, r1, r2 );
    check( false, r1, r3 );
    check( false, r1, r4 );
View Full Code Here

        }
      };
    }

    public NativeSQLQueryReturn buildReturn() {
      return new NativeSQLQueryJoinReturn( alias, ownerTableAlias, joinedPropertyName, propertyMappings, lockMode );
    }
View Full Code Here

    String roleProperty = roleAttribute.substring( dot + 1 );

    //FIXME: get the PersistentClass
    java.util.Map propertyResults = bindPropertyResults(alias, returnElem, null, mappings );

    return new NativeSQLQueryJoinReturn(
        alias,
        roleOwnerAlias,
        roleProperty,
        propertyResults, // TODO: bindpropertyresults(alias, returnElem)
        lockMode
View Full Code Here

    if ( loc < 0 ) {
      throw new QueryException( "not a property path: " + path );
    }
    String ownerAlias = path.substring(0, loc);
    String role = path.substring(loc+1);
    queryReturns.add( new NativeSQLQueryJoinReturn(alias, ownerAlias, role, CollectionHelper.EMPTY_MAP, lockMode) );
    return this;
  }
View Full Code Here

    for ( int i = 0; i < queryReturns.length; i++ ) {
      if ( queryReturns[i] instanceof NativeSQLQueryNonScalarReturn ) {
        NativeSQLQueryNonScalarReturn rtn = ( NativeSQLQueryNonScalarReturn ) queryReturns[i];
        alias2Return.put( rtn.getAlias(), rtn );
        if ( rtn instanceof NativeSQLQueryJoinReturn ) {
          NativeSQLQueryJoinReturn fetchReturn = ( NativeSQLQueryJoinReturn ) rtn;
          alias2OwnerAlias.put( fetchReturn.getAlias(), fetchReturn.getOwnerAlias() );
        }
      }
    }

    // Now, process the returns
View Full Code Here

        );
        customReturns.add( customReturn );
        customReturnsByAlias.put( rtn.getAlias(), customReturn );
      }
      else if ( queryReturns[i] instanceof NativeSQLQueryJoinReturn ) {
        NativeSQLQueryJoinReturn rtn = ( NativeSQLQueryJoinReturn ) queryReturns[i];
        String alias = rtn.getAlias();
        FetchReturn customReturn;
        NonScalarReturn ownerCustomReturn = ( NonScalarReturn ) customReturnsByAlias.get( rtn.getOwnerAlias() );
        if ( alias2CollectionPersister.containsKey( alias ) ) {
          SQLLoadableCollection persister = ( SQLLoadableCollection ) alias2CollectionPersister.get( alias );
          boolean isEntityElements = persister.getElementType().isEntityType();
          CollectionAliases collectionAliases;
          EntityAliases elementEntityAliases = null;
          if ( queryHadAliases || hasPropertyResultMap( alias ) ) {
            collectionAliases = new GeneratedCollectionAliases(
                ( Map ) collectionPropertyResultMaps.get( alias ),
                persister,
                ( String ) alias2CollectionSuffix.get( alias )
            );
            if ( isEntityElements ) {
              elementEntityAliases = new DefaultEntityAliases(
                  ( Map ) entityPropertyResultMaps.get( alias ),
                  ( SQLLoadable ) alias2Persister.get( alias ),
                  ( String ) alias2Suffix.get( alias )
              );
            }
          }
          else {
            collectionAliases = new ColumnCollectionAliases(
                ( Map ) collectionPropertyResultMaps.get( alias ),
                persister
            );
            if ( isEntityElements ) {
              elementEntityAliases = new ColumnEntityAliases(
                  ( Map ) entityPropertyResultMaps.get( alias ),
                  ( SQLLoadable ) alias2Persister.get( alias ),
                  ( String ) alias2Suffix.get( alias )
              );
            }
          }
          customReturn = new CollectionFetchReturn(
              alias,
              ownerCustomReturn,
              rtn.getOwnerProperty(),
              collectionAliases,
                  elementEntityAliases,
              rtn.getLockMode()
          );
        }
        else {
          EntityAliases entityAliases;
          if ( queryHadAliases || hasPropertyResultMap( alias ) ) {
            entityAliases = new DefaultEntityAliases(
                ( Map ) entityPropertyResultMaps.get( alias ),
                ( SQLLoadable ) alias2Persister.get( alias ),
                ( String ) alias2Suffix.get( alias )
            );
          }
          else {
            entityAliases = new ColumnEntityAliases(
                ( Map ) entityPropertyResultMaps.get( alias ),
                ( SQLLoadable ) alias2Persister.get( alias ),
                ( String ) alias2Suffix.get( alias )
            );
          }
          customReturn = new EntityFetchReturn(
              alias,
              entityAliases,
              ownerCustomReturn,
              rtn.getOwnerProperty(),
              rtn.getLockMode()
          );
        }
        customReturns.add( customReturn );
        customReturnsByAlias.put( alias, customReturn );
      }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.