Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-298

Allow Entity to hold a collection of a single primitive type

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: 2.x
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Sometimes you want to save arbitrary information for an entity using a key -> value array-structure. JPA supports this by means of the @ElementCollection annotation with allows to specify HashMaps for example.

      I propose a new AssocationMapping called "ElementMapping" / "ElementCollection" and annotations (options):

      ElementCollection
      + elementTable
      + keyType
      + keyLength
      + keyColumnDefinition
      + valueType
      + valueLength
      + valueColumnDefinition
      

      The key and value definitions are necessary for converting and schema generation.

      The implementation would make use of the PersistentCollection at all times and work as any other persistent collection just with primitive types.

      Restrictions for a first implementation:

      • Only available as a Lazy-Load Collection, no hydration with the source entity
      • Can't be used in queries alike "entity.colname.key = ?1"

      Use-Case:

      $entity->options['foo'] = 'bar';
      $entity->options['bar'] = 'baz';
      

      This could be done for 2.0 imho, adding the necessary changes and optimizations could then be scheduled for 2.1

        Issue Links

          Activity

          beberlei Benjamin Eberlei created issue -
          beberlei Benjamin Eberlei made changes -
          Field Original Value New Value
          Description Sometimes you want to save arbitrary information for an entity using a key -> value array-structure. JPA supports this by means of the @ElementCollection annotation with allows to specify HashMaps for example.

          I propose a new AssocationMapping called "ElementMapping" / "ElementCollection" and annotations (options):

          {code}
          ElementCollection
          + elementTable
          + keyType
          + keyLength
          + keyColumnDefinition
          + valueType
          + valueLength
          + valueColumnDefinition
          {code}

          The key and value definitions are necessary for converting and schema generation.

          The implementation would make use of the PersistentCollection at all times and work as any other persistent collection just with primitive types.

          Restrictions for a first implementation:

          * Only available as a Lazy-Load Collection, no hydration with the source entity
          * Can't be used in queries alike "entity.colname.key = ?1"

          This could be done for 2.0 imho, adding the necessary changes and optimizations could then be scheduled for 2.1
          Sometimes you want to save arbitrary information for an entity using a key -> value array-structure. JPA supports this by means of the @ElementCollection annotation with allows to specify HashMaps for example.

          I propose a new AssocationMapping called "ElementMapping" / "ElementCollection" and annotations (options):

          {code}
          ElementCollection
          + elementTable
          + keyType
          + keyLength
          + keyColumnDefinition
          + valueType
          + valueLength
          + valueColumnDefinition
          {code}

          The key and value definitions are necessary for converting and schema generation.

          The implementation would make use of the PersistentCollection at all times and work as any other persistent collection just with primitive types.

          Restrictions for a first implementation:

          * Only available as a Lazy-Load Collection, no hydration with the source entity
          * Can't be used in queries alike "entity.colname.key = ?1"

          Use-Case:

          {code}
          $entity->options['foo'] = 'bar';
          $entity->options['bar'] = 'baz';
          {code}

          This could be done for 2.0 imho, adding the necessary changes and optimizations could then be scheduled for 2.1
          Hide
          beberlei Benjamin Eberlei added a comment -

          In this implementation Schema-Tool would generate a table:

          elementTable (entity_id-1, ..., entity_id-n, key, value) and using the Platform Type Generation of keyType and valueType

          Show
          beberlei Benjamin Eberlei added a comment - In this implementation Schema-Tool would generate a table: elementTable (entity_id-1, ..., entity_id-n, key, value) and using the Platform Type Generation of keyType and valueType
          Hide
          beberlei Benjamin Eberlei added a comment -

          Column Names should be Change-able also since there could be people who name their primary keys "key" and "value" o_O

          Show
          beberlei Benjamin Eberlei added a comment - Column Names should be Change-able also since there could be people who name their primary keys "key" and "value" o_O
          Hide
          beberlei Benjamin Eberlei added a comment -

          Ordering could be implemented on top of this using the @OrderColumn JPA implementation by adding another column to the table with a numeric order that will be "order by"'d on select time.

          Show
          beberlei Benjamin Eberlei added a comment - Ordering could be implemented on top of this using the @OrderColumn JPA implementation by adding another column to the table with a numeric order that will be "order by"'d on select time.
          romanb Roman S. Borschel made changes -
          Fix Version/s 2.1 [ 10022 ]
          Hide
          beberlei Benjamin Eberlei added a comment -

          Pushed back

          Show
          beberlei Benjamin Eberlei added a comment - Pushed back
          beberlei Benjamin Eberlei made changes -
          Fix Version/s 2.x [ 10090 ]
          Fix Version/s 2.1 [ 10022 ]
          beberlei Benjamin Eberlei made changes -
          Workflow jira [ 10829 ] jira-feedback [ 13841 ]
          beberlei Benjamin Eberlei made changes -
          Workflow jira-feedback [ 13841 ] jira-feedback2 [ 15705 ]
          beberlei Benjamin Eberlei made changes -
          Workflow jira-feedback2 [ 15705 ] jira-feedback3 [ 17962 ]
          Hide
          myknbani Richard Michael Coo added a comment -

          Any news on this? It has been almost 3 years since its last update =)

          Show
          myknbani Richard Michael Coo added a comment - Any news on this? It has been almost 3 years since its last update =)
          beberlei Benjamin Eberlei made changes -
          Link This issue is duplicated by DDC-2806 [ DDC-2806 ]

          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={expand=changesets[0:20].revisions[0:29],reviews, query=DDC-298}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

            • Assignee:
              beberlei Benjamin Eberlei
              Reporter:
              beberlei Benjamin Eberlei
            • Votes:
              6 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated: