Package org.hibernate.ogm.grid

Examples of org.hibernate.ogm.grid.EntityKey


   * @param associationKey identify the type of the relationship
   * @param rowKey identify the relationship
   * @return the corresponding relationship
   */
  public Relationship findRelationship(AssociationKey associationKey, RowKey rowKey) {
    EntityKey entityKey = associationKey.getEntityKey();
    Map<String, Object> parameters = new HashMap<String, Object>( entityKey.getColumnNames().length + rowKey.getColumnNames().length );
    StringBuilder query = new StringBuilder( "MATCH" );
    appendNodePattern( entityKey, parameters, query, ENTITY );
    query.append( " - " );
    query.append( relationshipCypher( associationKey, rowKey, parameters, entityKey.getColumnNames().length ) );
    query.append( " - () RETURN r" );
    ExecutionResult result = engine.execute( query.toString(), parameters );
    ResourceIterator<Relationship> column = result.columnAs( "r" );
    Relationship relationship = null;
    if ( column.hasNext() ) {
View Full Code Here


  @Override
  public void lock(Serializable id, Object version, Object object, int timeout, SessionImplementor session)
      throws StaleObjectStateException, JDBCException {
    AdvancedCache advCache = getProvider( session ).getCache( ENTITY_STORE ).getAdvancedCache();
    EntityKey key = EntityKeyBuilder.fromData(
        ( (OgmEntityPersister) lockable).getRootEntityKeyMetadata(),
        identifierGridType,
        id,
        session );
    advCache.lock( key );
View Full Code Here

    String tableName = input.readUTF();
    String[] columnNames = (String[]) input.readObject();
    Object[] values = (Object[]) input.readObject();

    return new EntityKey( new EntityKeyMetadata( tableName, columnNames ), values );
  }
View Full Code Here

  private void updateInverseSideOfAssociationNavigation(SessionImplementor session, Map<String, Object> tuple, Action action, RowKey rowKey) {
    if ( associationType == AssociationType.EMBEDDED_FK_TO_ENTITY ) {
      //update the associated object
      Serializable entityId = (Serializable) gridTypeOfAssociatedId.nullSafeGet( tuple, getElementColumnNames(), session, null );
      final EntityKey entityKey = new EntityKeyBuilder()
          .entityPersister( ( OgmEntityPersister ) getElementPersister() )
          .id( entityId )
          .getKey();
      final Cache<EntityKey,Map<String,Object>> entityCache = GridMetadataManagerHelper.getEntityCache(
          gridManager
View Full Code Here

  private TupleAsMapResultSet getResultSet(Serializable id, SessionImplementor session) {
    //TODO this if won't work when we will support collections inside the entity tuple but that will do for now
    final TupleAsMapResultSet resultset = new TupleAsMapResultSet();
    if ( getEntityPersisters().length > 0 ) {
      final Cache<EntityKey, Map<String, Object>> entityCache = GridMetadataManagerHelper.getEntityCache( gridManager );
      final EntityKey key = new EntityKeyBuilder()
          .entityPersister( getEntityPersisters()[0] )
          .id( id )
          .getKey();
      final Map<String,Object> entry = gridManager.getGridDialect().getTuple( key, entityCache );
      if ( entry != null ) {
View Full Code Here

    this.id = id;
    return this;
  }

  public EntityKey getKey() {
    return new EntityKey(
        tableName != null ? tableName : persister.getTableName(),
        id
    );
  }
View Full Code Here

    }
    return values;
  }

  private Map<String, Object> getResultsetById(Serializable id, Cache<EntityKey, Map<String, Object>> cache) {
    final EntityKey key = new EntityKeyBuilder().entityPersister( this ).id( id ).getKey();
    final Map<String,Object> resultset = gridManager.getGridDialect().getTuple(key,cache);
    return resultset;
  }
View Full Code Here

    /*
     * We get the value from the grid and compare the version values before putting the next version in
     * Contrary to the database version, there is
     * TODO should we use cache.replace() it seems more expensive to pass the resultset around "just" the atomicity of the operation
     */
    final EntityKey key = new EntityKeyBuilder().entityPersister( this ).id(id).getKey();
    final GridDialect gridDialect = gridManager.getGridDialect();
    final Map<String, Object> resultset = gridDialect.getTuple( key, entityCache );
    checkVersionAndRaiseSOSE(id, currentVersion, session, resultset);
    gridVersionType.nullSafeSet( resultset, nextVersion, new String[] { getVersionColumnName() }, session );
    gridDialect.updateTuple( resultset, key, entityCache );
View Full Code Here

    final Cache<EntityKey, Map<String, Object>> entityCache = GridMetadataManagerHelper.getEntityCache( gridManager );
    final GridDialect gridDialect = gridManager.getGridDialect();
    for ( int j = 0; j < span; j++ ) {
      // Now update only the tables with dirty properties (and the table with the version number)
      if ( tableUpdateNeeded[j] ) {
        final EntityKey key = new EntityKeyBuilder().entityPersister( this ).id(id).getKey();
        Map<String, Object> resultset = gridDialect.getTuple( key, entityCache );
        final boolean useVersion = j == 0 && isVersioned();

        resultset = createNewResultSetIfNull( key, entityCache, resultset, id, session );
View Full Code Here

        if ( j == 0 && isVersioned() ) {
          log.trace( "Version: " + Versioning.getVersion( fields, this ) );
        }
      }

      final EntityKey key = new EntityKeyBuilder().entityPersister( this ).id(id).getKey();
      Map<String, Object> resultset = gridDialect.getTuple( key, entityCache );
      // add the discriminator
      if ( j == 0 ) {
        if (resultset != null) {
          throw new HibernateException( "trying to insert an already existing entity: "
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.grid.EntityKey

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.