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 New Feature
    • Status: Open
    • Priority: Major 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

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Benjamin Eberlei
            • Votes:
              5 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated: