Details

    • Type: Improvement Improvement
    • Status: Reopened
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0-ALPHA4
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      The TableGenerator Id Generator is not yet implemented, here is some code i came up with:

      class TableGenerator extends AbstractIdGenerator
      {
          private $_tableName;
          private $_sequenceName;
          private $_allocationSize;
          private $_nextValue;
          private $_maxValue;
      
          public function __construct($tableName, $sequenceName = 'default', $allocationSize = 10)
          {
              $this->_tableName = $tableName;
              $this->_sequenceName = $sequenceName;
              $this->_allocationSize = $allocationSize;
          }
      
          public function generate(EntityManager $em, $entity)
          {
              if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) {
                  // Allocate new values
                  $conn = $em->getConnection();
                  if ($conn->getTransactionNestingLevel() == 0) {
      
                      // use select for update
                      $sql = $conn->getDatabasePlatform()->getTableHiLoCurrentValSql($this->_tableName, $this->_sequenceName);
                      $currentLevel = $conn->fetchColumn($sql);
                      if ($currentLevel != null) {
                          $this->_nextValue = $currentLevel;
                          $this->_maxValue = $this->_nextValue + $this->_allocationSize;
      
                          $updateSql = $conn->getDatabasePlatform()->getTableHiLoUpdateNextValSql(
                              $this->_tableName, $this->_sequenceName, $this->_allocationSize
                          );
                          
                          if ($conn->executeUpdate($updateSql, array(1 => $currentLevel, 2 => $currentLevel+1)) !== 1) {
                              // no affected rows, concurrency issue, throw exception
                          }
                      } else {
                          // no current level returned, TableGenerator seems to be broken, throw exception
                      }
                  } else {
                      // only table locks help here, implement this or throw exception?
                      // or do we want to work with table locks exclusively?
                  }
              }
              return $this->_nextValue++;
          }
      }
      

        Issue Links

          Activity

          Benjamin Eberlei created issue -
          Hide
          Guilherme Blanco added a comment -

          Already merged into core.

          Show
          Guilherme Blanco added a comment - Already merged into core.
          Guilherme Blanco made changes -
          Field Original Value New Value
          Status Open [ 1 ] Closed [ 6 ]
          Fix Version/s 2.0-BETA2 [ 10050 ]
          Fix Version/s 2.0 [ 10021 ]
          Resolution Fixed [ 1 ]
          Hide
          Benjamin Eberlei added a comment -

          But it is not enabled yet Plus we need tests to verify this works in high concurrency enviroments and does not pass the same id twice.

          Furthermore the DAtabase Platform Methods are completly missing. No implementations yet.

          Show
          Benjamin Eberlei added a comment - But it is not enabled yet Plus we need tests to verify this works in high concurrency enviroments and does not pass the same id twice. Furthermore the DAtabase Platform Methods are completly missing. No implementations yet.
          Benjamin Eberlei made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Hide
          Benjamin Eberlei added a comment -

          Schema-Tool support is also missing.

          Show
          Benjamin Eberlei added a comment - Schema-Tool support is also missing.
          Roman S. Borschel made changes -
          Fix Version/s 2.0-BETA2 [ 10050 ]
          Benjamin Eberlei made changes -
          Link This issue depends on DBAL-223 [ DBAL-223 ]
          Benjamin Eberlei made changes -
          Workflow jira [ 11100 ] jira-feedback [ 14099 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback [ 14099 ] jira-feedback2 [ 15963 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback2 [ 15963 ] jira-feedback3 [ 18217 ]

          This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

          • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-450, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

            • Assignee:
              Roman S. Borschel
              Reporter:
              Benjamin Eberlei
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: