Package org.camunda.bpm.engine.impl.db

Examples of org.camunda.bpm.engine.impl.db.DbEntity


  // insert //////////////////////////////////////////

  protected void insertEntity(DbEntityOperation operation) {

    final DbEntity dbEntity = operation.getEntity();

    // get statement
    String insertStatement = dbSqlSessionFactory.getInsertStatement(dbEntity);
    insertStatement = dbSqlSessionFactory.mapStatement(insertStatement);
    ensureNotNull("no insert statement for " + dbEntity.getClass() + " in the ibatis mapping files", "insertStatement", insertStatement);

    // execute the insert
    executeInsertEntity(insertStatement, dbEntity);

    // perform post insert actions on entity
View Full Code Here


  // delete ///////////////////////////////////////////

  protected void deleteEntity(DbEntityOperation operation) {

    final DbEntity dbEntity = operation.getEntity();

    // get statement
    String deleteStatement = dbSqlSessionFactory.getDeleteStatement(dbEntity.getClass());
    ensureNotNull("no delete statement for " + dbEntity.getClass() + " in the ibatis mapping files", "deleteStatement", deleteStatement);

    if(log.isLoggable(Level.FINE)) {
      log.fine("deleting: " + toString(dbEntity));
    }
View Full Code Here

  // update ////////////////////////////////////////

  protected void updateEntity(DbEntityOperation operation) {

    final DbEntity dbEntity = operation.getEntity();

    String updateStatement = dbSqlSessionFactory.getUpdateStatement(dbEntity);
    ensureNotNull("no update statement for " + dbEntity.getClass() + " in the ibatis mapping files", "updateStatement", updateStatement);

    if (log.isLoggable(Level.FINE)) {
      log.fine("updating: " + toString(dbEntity));
    }
View Full Code Here

  protected String toString(Object object) {
    if(object == null) {
      return "null";
    }
    if(object instanceof DbEntity) {
      DbEntity dbEntity = (DbEntity) object;
      return ClassNameUtil.getClassNameWithoutPackage(dbEntity)+"["+dbEntity.getId()+"]";
    }
    return object.toString();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public <T extends DbEntity> T get(Class<T> type, String id) {
    Class<?> cacheKey = cacheKeyMapping.getEntityCacheKey(type);
    CachedDbEntity cachedDbEntity = getCachedEntity(cacheKey, id);
    if(cachedDbEntity != null) {
      DbEntity dbEntity = cachedDbEntity.getEntity();
      try {
        return (T) dbEntity;
      } catch(ClassCastException e) {
        throw new ProcessEngineException("Could not lookup entity of type '"+type+"' and id '"+id+"': found entity of type '"+dbEntity.getClass()+"'.", e);
      }
    } else {
      return null;
    }
  }
View Full Code Here

  }

  public Object selectOne(String statement, Object parameter) {
    Object result = persistenceSession.selectOne(statement, parameter);
    if (result instanceof DbEntity) {
      DbEntity loadedObject = (DbEntity) result;
      result = cacheFilter(loadedObject);
    }
    return result;
  }
View Full Code Here

    if (! (DbEntity.class.isAssignableFrom(loadedObjects.get(0).getClass()))) {
      return loadedObjects;
    }
    List<DbEntity> filteredObjects = new ArrayList<DbEntity>(loadedObjects.size());
    for (Object loadedObject: loadedObjects) {
      DbEntity cachedPersistentObject = cacheFilter((DbEntity) loadedObject);
      filteredObjects.add(cachedPersistentObject);
    }
    return filteredObjects;
  }
View Full Code Here

  /** returns the object in the cache.  if this object was loaded before,
   * then the original object is returned.  if this is the first time
   * this object is loaded, then the loadedObject is added to the cache. */
  protected DbEntity cacheFilter(DbEntity persistentObject) {
    DbEntity cachedPersistentObject = dbEntityCache.get(persistentObject.getClass(), persistentObject.getId());
    if (cachedPersistentObject!=null) {
      return cachedPersistentObject;
    }
    dbEntityCache.putPersistent(persistentObject);

View Full Code Here

    List<DbEntityOperation> opList = new ArrayList<DbEntityOperation>(preSorted);

    for (int i = 0; i < opList.size(); i++) {

      DbEntityOperation currentOperation = opList.get(i);
      DbEntity currentEntity = currentOperation.getEntity();

      // check whether this operation must be placed after another operation
      int moveTo = i;
      for(int k = i+1; k < opList.size(); k++) {
        DbEntityOperation otherOperation = opList.get(k);
        DbEntity otherEntity = otherOperation.getEntity();

        if(currentOperation.getOperationType() == INSERT) {
          // if we reference the other entity, we need to be inserted after that entity
          if(((HasDbReferences) currentEntity).hasReferenceTo(otherEntity)) {
            moveTo = k;
View Full Code Here

    if(firstOperation.equals(secondOperation)) {
      return 0;
    }

    DbEntity firstEntity = firstOperation.getEntity();
    DbEntity secondEntity = secondOperation.getEntity();

    return firstEntity.getId().compareTo(secondEntity.getId());
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.impl.db.DbEntity

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.