Package org.hibernate.ogm.persister

Examples of org.hibernate.ogm.persister.OgmEntityPersister


      if ( queryReturn instanceof RootReturn ) {
        if ( metadata != null ) {
          return null;
        }
        RootReturn rootReturn = (RootReturn) queryReturn;
        OgmEntityPersister persister = (OgmEntityPersister) sessionFactory.getEntityPersister( rootReturn.getEntityName() );
        metadata = new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
      }
    }

    return metadata;
  }
View Full Code Here


  public Object convertToPropertyType(String entityType, List<String> propertyPath, String value) {
    if ( propertyPath.size() > 1 ) {
      throw new UnsupportedOperationException( "Queries on embedded/associated entities are not supported yet." );
    }

    OgmEntityPersister persister = getPersister( entityType );

    Type propertyType = persister.getPropertyType( propertyPath.get( propertyPath.size() - 1 ) );

    if ( propertyType instanceof AbstractStandardBasicType ) {
      return ( (AbstractStandardBasicType<?>) propertyType ).fromString( value );
    }
    else {
View Full Code Here

      return value;
    }
  }

  public String getColumnName(String entityType, String propertyName) {
    OgmEntityPersister persister = getPersister( entityType );

    String columnName = propertyName;

    if ( columnName.equals( persister.getIdentifierPropertyName() ) ) {
      columnName = MongoDBDialect.ID_FIELDNAME;
    }
    else {
      String[] columnNames = persister.getPropertyColumnNames( columnName );
      columnName = columnNames[0];
    }

    return columnName;
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public Object load(Serializable id, Object optionalObject, SessionImplementor session, LockOptions lockOptions) {
    final OgmEntityPersister currentPersister = entityPersisters[0];
    if ( log.isDebugEnabled() ) {
      log.debug(
          "loading entity: " +
          MessageHelper.infoString( currentPersister, id, currentPersister.getIdentifierType(), session.getFactory() )
        );
    }
    QueryParameters qp = new QueryParameters();
    qp.setPositionalParameterTypes( new Type[] { currentPersister.getIdentifierType() } );
    qp.setPositionalParameterValues( new Object[] { id } );
    qp.setOptionalObject( optionalObject );
    qp.setOptionalEntityName( currentPersister.getEntityName() );
    qp.setOptionalId( id );
    qp.setLockOptions( lockOptions );

    Object result = doQueryAndInitializeNonLazyCollections(
        session,
View Full Code Here

  throws HibernateException {

    final Serializable id = key.getIdentifier();

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

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

    //FIXME figure out what that means and what value should be set
    //boolean eagerPropertyFetch = isEagerPropertyFetchEnabled(i);
    boolean eagerPropertyFetch = true;

    // 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
      );

    //TODO what to do with that in OGM
//    //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(
        resultset,
        id,
        object,
        rootPersister,
        //cols,
        eagerPropertyFetch,
        session
      );

    if ( persister.hasRowId() ) {
      throw new HibernateException( "Hibernate OGM does nto support row id");
    }
    final Object rowId = 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

      Neo4jQueryResolverDelegate resolverDelegate) {
    return SingleEntityQueryBuilder.getInstance( new Neo4jPredicateFactory( propertyHelper, resolverDelegate ), propertyHelper );
  }

  private EntityKeyMetadata getKeyMetaData(Class<?> entityType) {
    OgmEntityPersister persister = (OgmEntityPersister) ( sessionFactory ).getEntityPersister( entityType.getName() );
    return new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
  }
View Full Code Here

  @Override
  public Object convertToPropertyType(String entityType, List<String> propertyPath, String value) {
    if ( propertyPath.size() > 1 ) {
      throw new UnsupportedOperationException( "Queries on embedded/associated entities are not supported yet." );
    }
    OgmEntityPersister persister = getPersister( entityType );
    Type propertyType = persister.getPropertyType( propertyPath.get( propertyPath.size() - 1 ) );
    if ( propertyType instanceof AbstractStandardBasicType ) {
      return ( (AbstractStandardBasicType<?>) propertyType ).fromString( value );
    }
    else {
      return value;
View Full Code Here

  public Object convertToLiteral(String entityType, List<String> propertyPath, Object value) {
    if ( propertyPath.size() > 1 ) {
      throw new UnsupportedOperationException( "Queries on embedded/associated entities are not supported yet." );
    }
    OgmEntityPersister persister = getPersister( entityType );
    Type propertyType = persister.getPropertyType( propertyPath.get( propertyPath.size() - 1 ) );
    Object gridValue = convertToGridType( value, propertyType );
    return gridValue;
  }
View Full Code Here

      if (collectionPersister != null) {
        EntityKey entityKey;
        // we are explicitly looking to update the non owning side
        if ( inverse ) {
          //look for the other side of the collection, build the key of the other side's entity
          OgmEntityPersister elementPersister = (OgmEntityPersister) collectionPersister.getElementPersister();
          entityKey = EntityKeyBuilder.fromPersister(
              elementPersister,
              (Serializable) key,
              session
          );
          collectionRole = buildCollectionRole( collectionPersister );
        }
        else {
          //we are on the right side, use the association property
          collectionRole = getUnqualifiedRole( collectionPersister );
          entityKey = EntityKeyBuilder.fromPersister(
              (OgmEntityPersister) collectionPersister.getOwnerEntityPersister(),
              (Serializable) key,
              session
          );
        }
        ownerEntityKey = entityKey;
        //TODO add information on the collection type, set, map, bag, list etc

        AssociationKind type = collectionPersister.getElementType().isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED_COLLECTION;
        associationKind = type;
      }
      // We have a to-one on the main side
      else if ( propertyType != null ) {
        associationKind = propertyType.isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED_COLLECTION;
        if ( propertyType instanceof EntityType ) {
          EntityType entityType = (EntityType) propertyType;
          OgmEntityPersister associatedPersister = (OgmEntityPersister) entityType.getAssociatedJoinable( session.getFactory() );
          EntityKey entityKey = new EntityKey(
              associatedPersister.getEntityKeyMetadata(),
              columnValues
          );
          ownerEntityKey = entityKey;
          collectionRole = getCollectionRoleFromToOne( associatedPersister );
        }
View Full Code Here

      // If that's a OneToOne check the associated property name and see if it matches where we come from
      // we need to do that as OneToOne don't define columns
      OneToOneType oneToOneType = (OneToOneType) type;
      String associatedProperty = oneToOneType.getRHSUniqueKeyPropertyName();
      if ( associatedProperty != null ) {
        OgmEntityPersister mainSidePersister = (OgmEntityPersister) oneToOneType.getAssociatedJoinable( session.getFactory() );
        try {
          int propertyIndex = mainSidePersister.getPropertyIndex( associatedProperty );
          return mainSidePersister.getPropertyTypes()[propertyIndex] == propertyType;
        }
        catch ( HibernateException e ) {
          //not the right property
          //probably should not happen
        }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.persister.OgmEntityPersister

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.