Package org.hibernate.persister.entity

Examples of org.hibernate.persister.entity.Loadable


  throws SQLException, HibernateException {

    final Serializable id = key.getIdentifier();

    // Get the persister for the _subclass_
    final Loadable persister = (Loadable) getFactory().getEntityPersister( instanceEntityName );

        if (LOG.isTraceEnabled()) LOG.trace("Initializing object from ResultSet: "
                                            + MessageHelper.infoString(persister, id, getFactory()));

    boolean eagerPropertyFetch = isEagerPropertyFetchEnabled(i);

    // add temp entry so that the next step is circular-reference
    // safe - only needed because some types don't take proper
    // advantage of two-phase-load (esp. components)
    TwoPhaseLoad.addUninitializedEntity(
        key,
        object,
        persister,
        lockMode,
        !eagerPropertyFetch,
        session
      );

    //This is not very nice (and quite slow):
    final String[][] cols = persister == rootPersister ?
        getEntityAliases()[i].getSuffixedPropertyAliases() :
        getEntityAliases()[i].getSuffixedPropertyAliases(persister);

    final Object[] values = persister.hydrate(
        rs,
        id,
        object,
        rootPersister,
        cols,
        eagerPropertyFetch,
        session
      );

    final Object rowId = persister.hasRowId() ? rs.getObject(rowIdAlias) : null;

    final AssociationType[] ownerAssociationTypes = getOwnerAssociationTypes();
    if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) {
      String ukName = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName();
      if (ukName!=null) {
        final int index = ( (UniqueKeyLoadable) persister ).getPropertyIndex(ukName);
        final Type type = persister.getPropertyTypes()[index];

        // polymorphism not really handled completely correctly,
        // perhaps...well, actually its ok, assuming that the
        // entity name used in the lookup is the same as the
        // the one used here, which it will be
View Full Code Here


  throws SQLException, HibernateException {

    final Serializable id = key.getIdentifier();

    // Get the persister for the _subclass_
    final Loadable persister = (Loadable) getFactory().getEntityPersister( instanceEntityName );

    if ( LOG.isTraceEnabled() )
      LOG.tracev( "Initializing object from ResultSet: {0}", MessageHelper.infoString( persister, id, getFactory() ) );

    boolean eagerPropertyFetch = isEagerPropertyFetchEnabled(i);

    // add temp entry so that the next step is circular-reference
    // safe - only needed because some types don't take proper
    // advantage of two-phase-load (esp. components)
    TwoPhaseLoad.addUninitializedEntity(
        key,
        object,
        persister,
        lockMode,
        !eagerPropertyFetch,
        session
      );

    //This is not very nice (and quite slow):
    final String[][] cols = persister == rootPersister ?
        getEntityAliases()[i].getSuffixedPropertyAliases() :
        getEntityAliases()[i].getSuffixedPropertyAliases(persister);

    final Object[] values = persister.hydrate(
        rs,
        id,
        object,
        rootPersister,
        cols,
        eagerPropertyFetch,
        session
      );

    final Object rowId = persister.hasRowId() ? rs.getObject(rowIdAlias) : null;

    final AssociationType[] ownerAssociationTypes = getOwnerAssociationTypes();
    if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) {
      String ukName = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName();
      if (ukName!=null) {
        final int index = ( (UniqueKeyLoadable) persister ).getPropertyIndex(ukName);
        final Type type = persister.getPropertyTypes()[index];

        // polymorphism not really handled completely correctly,
        // perhaps...well, actually its ok, assuming that the
        // entity name used in the lookup is the same as the
        // the one used here, which it will be

        EntityUniqueKey euk = new EntityUniqueKey(
            rootPersister.getEntityName(), //polymorphism comment above
            ukName,
            type.semiResolve( values[index], session, object ),
            type,
            persister.getEntityMode(),
            session.getFactory()
        );
        session.getPersistenceContext().addEntity( euk, object );
      }
    }
View Full Code Here

   * Otherwise use the table name
   */
  //TODO we could cache such knowledge in a service if that turns out to be costly
  private String buildCollectionRole(OgmCollectionPersister collectionPersister) {
    String otherSidePropertyName = null;
    Loadable elementPersister = (Loadable) collectionPersister.getElementPersister();
    Type[] propertyTypes = elementPersister.getPropertyTypes();

    for ( int index = 0 ; index <  propertyTypes.length ; index++ ) {
      Type type = propertyTypes[index];
      //we try and restrict type search as much as possible
      if ( type.isAssociationType() ) {
        boolean matching = false;
        //if the main side collection is a one-to-many, the reverse side should be a to-one is not a collection
        if ( collectionPersister.isOneToMany() && ! type.isCollectionType() ) {
          matching = isToOneMatching( elementPersister, index, type );
        }
        //if the main side collection is not a one-to-many, the reverse side should be a collection
        else if ( ! collectionPersister.isOneToMany() && type.isCollectionType() ) {
          matching = isCollectionMatching( (CollectionType) type, collectionPersister.getTableName() );
        }
        if ( matching ) {
          otherSidePropertyName = elementPersister.getPropertyNames()[index];
          break;
        }
      }
    }
    return processOtherSidePropertyName( otherSidePropertyName );
View Full Code Here

  public Type getIdentifierType(Criteria subcriteria) {
    return ( ( Loadable ) getPropertyMapping( getEntityName( subcriteria ) ) ).getIdentifierType();
  }

  public TypedValue getTypedIdentifierValue(Criteria subcriteria, Object value) {
    final Loadable loadable = ( Loadable ) getPropertyMapping( getEntityName( subcriteria ) );
    return new TypedValue(
        loadable.getIdentifierType(),
            value,
            EntityMode.POJO
    );
  }
View Full Code Here

  throws SQLException, HibernateException {

    final Serializable id = key.getIdentifier();

    // Get the persister for the _subclass_
    final Loadable persister = (Loadable) getFactory().getEntityPersister( instanceEntityName );

    if ( log.isTraceEnabled() ) {
      log.trace(
          "Initializing object from ResultSet: " +
          MessageHelper.infoString( persister, id, getFactory() )
        );
    }
   
    boolean eagerPropertyFetch = isEagerPropertyFetchEnabled(i);

    // add temp entry so that the next step is circular-reference
    // safe - only needed because some types don't take proper
    // advantage of two-phase-load (esp. components)
    TwoPhaseLoad.addUninitializedEntity(
        key,
        object,
        persister,
        lockMode,
        !eagerPropertyFetch,
        session
      );

    //This is not very nice (and quite slow):
    final String[][] cols = persister == rootPersister ?
        getEntityAliases()[i].getSuffixedPropertyAliases() :
        getEntityAliases()[i].getSuffixedPropertyAliases(persister);

    final Object[] values = persister.hydrate(
        rs,
        id,
        object,
        rootPersister,
        cols,
        eagerPropertyFetch,
        session
      );

    final Object rowId = persister.hasRowId() ? rs.getObject(rowIdAlias) : null;

    final AssociationType[] ownerAssociationTypes = getOwnerAssociationTypes();
    if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) {
      String ukName = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName();
      if (ukName!=null) {
        final int index = ( (UniqueKeyLoadable) persister ).getPropertyIndex(ukName);
        final Type type = persister.getPropertyTypes()[index];
 
        // polymorphism not really handled completely correctly,
        // perhaps...well, actually its ok, assuming that the
        // entity name used in the lookup is the same as the
        // the one used here, which it will be
View Full Code Here

  throws SQLException, HibernateException {

    final Serializable id = key.getIdentifier();

    // Get the persister for the _subclass_
    final Loadable persister = (Loadable) getFactory().getEntityPersister( instanceEntityName );

    if ( LOG.isTraceEnabled() )
      LOG.tracev( "Initializing object from ResultSet: {0}", MessageHelper.infoString( persister, id, getFactory() ) );

    boolean eagerPropertyFetch = isEagerPropertyFetchEnabled(i);

    // add temp entry so that the next step is circular-reference
    // safe - only needed because some types don't take proper
    // advantage of two-phase-load (esp. components)
    TwoPhaseLoad.addUninitializedEntity(
        key,
        object,
        persister,
        lockMode,
        !eagerPropertyFetch,
        session
      );

    //This is not very nice (and quite slow):
    final String[][] cols = persister == rootPersister ?
        getEntityAliases()[i].getSuffixedPropertyAliases() :
        getEntityAliases()[i].getSuffixedPropertyAliases(persister);

    final Object[] values = persister.hydrate(
        rs,
        id,
        object,
        rootPersister,
        cols,
        eagerPropertyFetch,
        session
      );

    final Object rowId = persister.hasRowId() ? rs.getObject(rowIdAlias) : null;

    final AssociationType[] ownerAssociationTypes = getOwnerAssociationTypes();
    if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) {
      String ukName = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName();
      if (ukName!=null) {
        final int index = ( (UniqueKeyLoadable) persister ).getPropertyIndex(ukName);
        final Type type = persister.getPropertyTypes()[index];

        // polymorphism not really handled completely correctly,
        // perhaps...well, actually its ok, assuming that the
        // entity name used in the lookup is the same as the
        // the one used here, which it will be

        EntityUniqueKey euk = new EntityUniqueKey(
            rootPersister.getEntityName(), //polymorphism comment above
            ukName,
            type.semiResolve( values[index], session, object ),
            type,
            persister.getEntityMode(),
            session.getFactory()
        );
        session.getPersistenceContext().addEntity( euk, object );
      }
    }
View Full Code Here

   * Otherwise use the table name
   */
  //TODO we could cache such knowledge in a service if that turns out to be costly
  private String buildCollectionRole(OgmCollectionPersister collectionPersister) {
    String otherSidePropertyName = null;
    Loadable elementPersister = (Loadable) collectionPersister.getElementPersister();
    Type[] propertyTypes = elementPersister.getPropertyTypes();

    for ( int index = 0 ; index <  propertyTypes.length ; index++ ) {
      Type type = propertyTypes[index];
      //we try and restrict type search as much as possible
      if ( type.isAssociationType() ) {
        boolean matching = false;
        //if the main side collection is a one-to-many, the reverse side should be a to-one is not a collection
        if ( collectionPersister.isOneToMany() && ! type.isCollectionType() ) {
          matching = isToOneMatching( elementPersister, index, type );
        }
        //if the main side collection is not a one-to-many, the reverse side should be a collection
        else if ( ! collectionPersister.isOneToMany() && type.isCollectionType() ) {
          matching = isCollectionMatching( (CollectionType) type, collectionPersister.getTableName() );
        }
        if ( matching ) {
          otherSidePropertyName = elementPersister.getPropertyNames()[index];
          break;
        }
      }
    }
    return processOtherSidePropertyName( otherSidePropertyName );
View Full Code Here

  public Type getIdentifierType(Criteria subcriteria) {
    return ( ( Loadable ) getPropertyMapping( getEntityName( subcriteria ) ) ).getIdentifierType();
  }

  public TypedValue getTypedIdentifierValue(Criteria subcriteria, Object value) {
    final Loadable loadable = ( Loadable ) getPropertyMapping( getEntityName( subcriteria ) );
    return new TypedValue(
        loadable.getIdentifierType(),
            value,
            EntityMode.POJO
    );
  }
View Full Code Here

  throws SQLException, HibernateException {

    final Serializable id = key.getIdentifier();

    // Get the persister for the _subclass_
    final Loadable persister = (Loadable) getFactory().getEntityPersister( instanceEntityName );

    if ( log.isTraceEnabled() ) {
      log.trace(
          "Initializing object from ResultSet: " +
          MessageHelper.infoString( persister, id, getFactory() )
        );
    }
   
    boolean eagerPropertyFetch = isEagerPropertyFetchEnabled(i);

    // add temp entry so that the next step is circular-reference
    // safe - only needed because some types don't take proper
    // advantage of two-phase-load (esp. components)
    TwoPhaseLoad.addUninitializedEntity(
        key,
        object,
        persister,
        lockMode,
        !eagerPropertyFetch,
        session
      );

    //This is not very nice (and quite slow):
    final String[][] cols = persister == rootPersister ?
        getEntityAliases()[i].getSuffixedPropertyAliases() :
        getEntityAliases()[i].getSuffixedPropertyAliases(persister);

    final Object[] values = persister.hydrate(
        rs,
        id,
        object,
        rootPersister,
        cols,
        eagerPropertyFetch,
        session
      );

    final Object rowId = persister.hasRowId() ? rs.getObject(rowIdAlias) : null;

    final AssociationType[] ownerAssociationTypes = getOwnerAssociationTypes();
    if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) {
      String ukName = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName();
      if (ukName!=null) {
        final int index = ( (UniqueKeyLoadable) persister ).getPropertyIndex(ukName);
        final Type type = persister.getPropertyTypes()[index];
 
        // polymorphism not really handled completely correctly,
        // perhaps...well, actually its ok, assuming that the
        // entity name used in the lookup is the same as the
        // the one used here, which it will be
View Full Code Here

  throws SQLException, HibernateException {

    final Serializable id = key.getIdentifier();

    // Get the persister for the _subclass_
    final Loadable persister = (Loadable) getFactory().getEntityPersister( instanceEntityName );

    if ( LOG.isTraceEnabled() )
      LOG.tracev( "Initializing object from ResultSet: {0}", MessageHelper.infoString( persister, id, getFactory() ) );

    boolean eagerPropertyFetch = isEagerPropertyFetchEnabled(i);

    // add temp entry so that the next step is circular-reference
    // safe - only needed because some types don't take proper
    // advantage of two-phase-load (esp. components)
    TwoPhaseLoad.addUninitializedEntity(
        key,
        object,
        persister,
        lockMode,
        !eagerPropertyFetch,
        session
      );

    //This is not very nice (and quite slow):
    final String[][] cols = persister == rootPersister ?
        getEntityAliases()[i].getSuffixedPropertyAliases() :
        getEntityAliases()[i].getSuffixedPropertyAliases(persister);

    final Object[] values = persister.hydrate(
        rs,
        id,
        object,
        rootPersister,
        cols,
        eagerPropertyFetch,
        session
      );

    final Object rowId = persister.hasRowId() ? rs.getObject(rowIdAlias) : null;

    final AssociationType[] ownerAssociationTypes = getOwnerAssociationTypes();
    if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) {
      String ukName = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName();
      if (ukName!=null) {
        final int index = ( (UniqueKeyLoadable) persister ).getPropertyIndex(ukName);
        final Type type = persister.getPropertyTypes()[index];

        // polymorphism not really handled completely correctly,
        // perhaps...well, actually its ok, assuming that the
        // entity name used in the lookup is the same as the
        // the one used here, which it will be

        EntityUniqueKey euk = new EntityUniqueKey(
            rootPersister.getEntityName(), //polymorphism comment above
            ukName,
            type.semiResolve( values[index], session, object ),
            type,
            persister.getEntityMode(),
            session.getFactory()
        );
        session.getPersistenceContext().addEntity( euk, object );
      }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.persister.entity.Loadable

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.