UPGRADE_TO_2_0 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. # Update from 2.0-BETA3 to 2.0-BETA4
  2. ## XML Driver <change-tracking-policy /> element demoted to attribute
  3. We changed how the XML Driver allows to define the change-tracking-policy. The working case is now:
  4. <entity change-tracking-policy="DEFERRED_IMPLICT" />
  5. # Update from 2.0-BETA2 to 2.0-BETA3
  6. ## Serialization of Uninitialized Proxies
  7. As of Beta3 you can now serialize uninitialized proxies, an exception will only be thrown when
  8. trying to access methods on the unserialized proxy as long as it has not been re-attached to the
  9. EntityManager using `EntityManager#merge()`. See this example:
  10. $proxy = $em->getReference('User', 1);
  11. $serializedProxy = serialize($proxy);
  12. $detachedProxy = unserialized($serializedProxy);
  13. echo $em->contains($detachedProxy); // FALSE
  14. try {
  15. $detachedProxy->getId(); // uninitialized detached proxy
  16. } catch(Exception $e) {
  17. }
  18. $attachedProxy = $em->merge($detachedProxy);
  19. echo $attackedProxy->getId(); // works!
  20. ## Changed SQL implementation of Postgres and Oracle DateTime types
  21. The DBAL Type "datetime" included the Timezone Offset in both Postgres and Oracle. As of this version they are now
  22. generated without Timezone (TIMESTAMP WITHOUT TIME ZONE instead of TIMESTAMP WITH TIME ZONE).
  23. See [this comment to Ticket DBAL-22](http://www.doctrine-project.org/jira/browse/DBAL-22?focusedCommentId=13396&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_13396)
  24. for more details as well as migration issues for PostgreSQL and Oracle.
  25. Both Postgres and Oracle will throw Exceptions during hydration of Objects with "DateTime" fields unless migration steps are taken!
  26. ## Removed multi-dot/deep-path expressions in DQL
  27. The support for implicit joins in DQL through the multi-dot/Deep Path Expressions
  28. was dropped. For example:
  29. SELECT u FROM User u WHERE u.group.name = ?1
  30. See the "u.group.id" here is using multi dots (deep expression) to walk
  31. through the graph of objects and properties. Internally the DQL parser
  32. would rewrite these queries to:
  33. SELECT u FROM User u JOIN u.group g WHERE g.name = ?1
  34. This explicit notation will be the only supported notation as of now. The internal
  35. handling of multi-dots in the DQL Parser was very complex, error prone in edge cases
  36. and required special treatment for several features we added. Additionally
  37. it had edge cases that could not be solved without making the DQL Parser
  38. even much more complex. For this reason we will drop the support for the
  39. deep path expressions to increase maintainability and overall performance
  40. of the DQL parsing process. This will benefit any DQL query being parsed,
  41. even those not using deep path expressions.
  42. Note that the generated SQL of both notations is exactly the same! You
  43. don't loose anything through this.
  44. ## Default Allocation Size for Sequences
  45. The default allocation size for sequences has been changed from 10 to 1. This step was made
  46. to not cause confusion with users and also because it is partly some kind of premature optimization.
  47. # Update from 2.0-BETA1 to 2.0-BETA2
  48. There are no backwards incompatible changes in this release.
  49. # Upgrade from 2.0-ALPHA4 to 2.0-BETA1
  50. ## EntityRepository deprecates access to protected variables
  51. Instead of accessing protected variables for the EntityManager in
  52. a custom EntityRepository it is now required to use the getter methods
  53. for all the three instance variables:
  54. * `$this->_em` now accessible through `$this->getEntityManager()`
  55. * `$this->_class` now accessible through `$this->getClassMetadata()`
  56. * `$this->_entityName` now accessible through `$this->getEntityName()`
  57. Important: For Beta 2 the protected visibility of these three properties will be
  58. changed to private!
  59. ## Console migrated to Symfony Console
  60. The Doctrine CLI has been replaced by Symfony Console Configuration
  61. Instead of having to specify:
  62. [php]
  63. $cliConfig = new CliConfiguration();
  64. $cliConfig->setAttribute('em', $entityManager);
  65. You now have to configure the script like:
  66. [php]
  67. $helperSet = new \Symfony\Components\Console\Helper\HelperSet(array(
  68. 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
  69. 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
  70. ));
  71. ## Console: No need for Mapping Paths anymore
  72. In previous versions you had to specify the --from and --from-path options
  73. to show where your mapping paths are from the console. However this information
  74. is already known from the Mapping Driver configuration, so the requirement
  75. for this options were dropped.
  76. Instead for each console command all the entities are loaded and to
  77. restrict the operation to one or more sub-groups you can use the --filter flag.
  78. ## AnnotationDriver is not a default mapping driver anymore
  79. In conjunction with the recent changes to Console we realized that the
  80. annotations driver being a default metadata driver lead to lots of glue
  81. code in the console components to detect where entities lie and how to load
  82. them for batch updates like SchemaTool and other commands. However the
  83. annotations driver being a default driver does not really help that much
  84. anyways.
  85. Therefore we decided to break backwards compability in this issue and drop
  86. the support for Annotations as Default Driver and require our users to
  87. specify the driver explicitly (which allows us to ask for the path to all
  88. entities).
  89. If you are using the annotations metadata driver as default driver, you
  90. have to add the following lines to your bootstrap code:
  91. $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
  92. $config->setMetadataDriverImpl($driverImpl);
  93. You have to specify the path to your entities as either string of a single
  94. path or array of multiple paths
  95. to your entities. This information will be used by all console commands to
  96. access all entities.
  97. Xml and Yaml Drivers work as before!
  98. ## New inversedBy attribute
  99. It is now *mandatory* that the owning side of a bidirectional association specifies the
  100. 'inversedBy' attribute that points to the name of the field on the inverse side that completes
  101. the association. Example:
  102. [php]
  103. // BEFORE (ALPHA4 AND EARLIER)
  104. class User
  105. {
  106. //...
  107. /** @OneToOne(targetEntity="Address", mappedBy="user") */
  108. private $address;
  109. //...
  110. }
  111. class Address
  112. {
  113. //...
  114. /** @OneToOne(targetEntity="User") */
  115. private $user;
  116. //...
  117. }
  118. // SINCE BETA1
  119. // User class DOES NOT CHANGE
  120. class Address
  121. {
  122. //...
  123. /** @OneToOne(targetEntity="User", inversedBy="address") */
  124. private $user;
  125. //...
  126. }
  127. Thus, the inversedBy attribute is the counterpart to the mappedBy attribute. This change
  128. was necessary to enable some simplifications and further performance improvements. We
  129. apologize for the inconvenience.
  130. ## Default Property for Field Mappings
  131. The "default" option for database column defaults has been removed. If desired, database column defaults can
  132. be implemented by using the columnDefinition attribute of the @Column annotation (or the approriate XML and YAML equivalents).
  133. Prefer PHP default values, if possible.
  134. ## Selecting Partial Objects
  135. Querying for partial objects now has a new syntax. The old syntax to query for partial objects
  136. now has a different meaning. This is best illustrated by an example. If you previously
  137. had a DQL query like this:
  138. [sql]
  139. SELECT u.id, u.name FROM User u
  140. Since BETA1, simple state field path expressions in the select clause are used to select
  141. object fields as plain scalar values (something that was not possible before).
  142. To achieve the same result as previously (that is, a partial object with only id and name populated)
  143. you need to use the following, explicit syntax:
  144. [sql]
  145. SELECT PARTIAL u.{id,name} FROM User u
  146. ## XML Mapping Driver
  147. The 'inheritance-type' attribute changed to take last bit of ClassMetadata constant names, i.e.
  148. NONE, SINGLE_TABLE, INHERITANCE_TYPE_JOINED
  149. ## YAML Mapping Driver
  150. The way to specify lifecycle callbacks in YAML Mapping driver was changed to allow for multiple callbacks
  151. per event. The Old syntax ways:
  152. [yaml]
  153. lifecycleCallbacks:
  154. doStuffOnPrePersist: prePersist
  155. doStuffOnPostPersist: postPersist
  156. The new syntax is:
  157. [yaml]
  158. lifecycleCallbacks:
  159. prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ]
  160. postPersist: [ doStuffOnPostPersist ]
  161. ## PreUpdate Event Listeners
  162. Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets
  163. by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes
  164. to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic
  165. performance benefits for the preUpdate event.
  166. ## Collection API
  167. The Collection interface in the Common package has been updated with some missing methods
  168. that were present only on the default implementation, ArrayCollection. Custom collection
  169. implementations need to be updated to adhere to the updated interface.