[DDC-1986] findBy hydration with limit and offset with Oracle database (oci8 driver) Created: 17/Aug/12 Updated: 08/Jan/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Grandfond | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | oracle | ||
| Environment: |
composer.json require : "php": ">=5.3.3", |
||
| Description |
|
I tried to use the findBy method with limit and offset parameters against an Oracle database using oci8 driver. The query seems to executed successfully but the hydrator fails when hydrating data as there is a DOCTRINE_ROWNUM column appending the "limit" clause. Here is the exception thrown : "Notice: Undefined index: DOCTRINE_ROWNUM in [...]/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php line 183" I was thinking about something like this to fix this issue
Maybe there is a better approach, what are your thoughts? |
| Comments |
| Comment by Benjamin Grandfond [ 17/Aug/12 ] |
|
I implemented it in my forks : https://github.com/benja-M-1/doctrine2/commit/c8d899b14446accf869ddc0043f4235284375755 It works for me, but I didn't write unit tests. |
| Comment by Benjamin Grandfond [ 24/Aug/12 ] |
|
Hi, Did you have time to have a look at this issue? Thanks |
| Comment by Christophe Coevoet [ 24/Aug/12 ] |
|
Please send a pull request when you submit a fix. It is the proper way to submit them for review. When we want to see things waiting for review, we look at the list of pending PRs, not at all comments of the issue tracker to find links in them. And I can tell you that this change has a big issue: it introduces a state in the database platform whereas it is currently stateless. This is likely to cause some issues when using more than 1 query (which is a common use case). |
| Comment by Benjamin Grandfond [ 29/Aug/12 ] |
|
Hi Christophe thank you for your feedback. I didn't send a PR because I wanted someone sharing his thoughts about what I suggested in this current issue. However I don't really understand the stateless argument, can you explain a bit more? Otherwise how would do you proceed to tell Doctrine not to hydrate platform-specific columns? |
| Comment by Christophe Coevoet [ 29/Aug/12 ] |
|
If you run several queries, they will be affected by the extra columns of previous requests, which is wrong |
| Comment by Benjamin Eberlei [ 29/Aug/12 ] |
|
I think the ObjectHydrator catches this by skipping undefined columns, i think we might just have overoptimized the SimpleObjectHydrator a little bit. |
[DDC-1879] Orphans are neither nulled nor removed when merging a graph of detached entities Created: 18/Jun/12 Updated: 23/Jan/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Philippe Van Eerdenbrugghe | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine 2.2.2 |
||
| Description |
|
When merging a graph of detached entities, the created entitied are created and the updated entities are updated but the non-present entities (which exist in the database but are not in the graph) are neither removed nor have them their association column nullified. Example : In my code I have 2 entities : Parent and Child. There is a OneToMany(cascade= {"all"}, orphanRemoval=true) relation defined in Parent. In my database I have a Parent row with an id of 1, which has 3 Children with ids 1,2,3. When I write the following code, I expect the Parent with id 1 and the Child with id 2 to be updated, a new Child to be created and the Child with id 1 and 3 to be deleted. $parent = new Parent(); $parent->id = 1 // detached entity $existing_child = new Child(); $child->id = 2 // detached entity $new_child = new Child(); // new entity $dinner->addChild($existing_child); $dinner->addChild($new_child); $em->merge($dinner); $em->flush(); The objects I expect to be created and updated have the correct behaviour but the old children are not touched, they are still present in the database. |
| Comments |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
I don't think this is valid. Orphan removal scheduling is handled only when an unit of work is available. What's the state of `$dinner` before your example? Can you `var_dump` it? |
[DDC-1803] Paginator usage with a DQL query that is using 2 time the same named binded value failed Created: 30/Apr/12 Updated: 25/Jan/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Marc Drolet | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
linux, oracle |
||
| Description |
|
I use a dql query where I bind a named parameter 2 time in the same query for different joined fields. The query work but the count query failed saying that there are missing bind variable. ex: , partial ca.{id} , ') $onTheMarket = new Paginator($qb, $fetchJoin = true); To make it work, I've renamed the second usage of the named variable with a 2 at the end. deleted2 and published2. |
| Comments |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
This seems to be quite old. Marc Drolet is it still valid with the latest ORM? |
| Comment by Marc Drolet [ 25/Jan/13 ] |
|
I'll try to test this problem on an updated version and I'll let you know. |
| Comment by Marco Pivetta [ 25/Jan/13 ] |
|
Ok, marking as awaiting feedback |
[DDC-2193] Named native query bug? Created: 11/Dec/12 Updated: 31/Dec/12 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | dingdangjyz | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
@NamedNativeQueries is a useful thing, but I have found some problems during my using.
/**
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "fetchMultipleJoinsEntityResults",
* resultSetMapping= "mappingMultipleJoinsEntityResults",
* query = "SELECT * FROM test "
* )
* })
*/
2、Error,cannot connect to the server
/**
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "fetchMultipleJoinsEntityResults",
* resultSetMapping= "mappingMultipleJoinsEntityResults",
* query = "SELECT *
FROM test "
* )
* })
*/
3、Cannot use alias.The same problem as the second one.
.......
query = "SELECT a as test FROM test "
|
| Comments |
| Comment by Fabio B. Silva [ 12/Dec/12 ] |
|
Hi Doctrine does not change the native query at all Could you provide more details please? Cheers |
| Comment by dingdangjyz [ 13/Dec/12 ] |
|
Doctrine\Common\Lexer.php Hello, after checking, I found the problem should be here. As long as SQL wrap, or fill in alias, it will be error. It seems to be the preg_split problem?
$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
$matches = preg_split($regex, $input, -1, $flags);
foreach ($matches as $match) {
// Must remain before 'value' assignment since it can change content
$type = $this->getType($match[0]);
$this->tokens[] = array(
'value' => $match[0],
'type' => $type,
'position' => $match[1],
);
|
| Comment by Fabio B. Silva [ 13/Dec/12 ] |
|
Hi Could you try to add a failing test case please ? Cheers |
| Comment by dingdangjyz [ 14/Dec/12 ] |
|
xp php5.3.8 Apache
<?php
namespace Models\Entities;
/**
* @Entity
* @Table
*
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "find-hotel-item",
* resultSetMapping = "mapping-find-item",
* query = "SELECT Top 1 VEI_SN AS SN
FROM tourmanager.dbo.VEndorInfo vi
INNER JOIN tourmanager.dbo.VEndorInfo2 vi2 ON
vi.VEI_SN = vi2.VEI2_VEI_SN LEFT OUTER JOIN tourmanager.dbo.HotelInfo hi
ON hi.hotelid = vi2.VEI2_VEI_SN INNER JOIN tourmanager.dbo.HotelInfo2
hi2 ON hi2.hotelid = vi2.VEI2_VEI_SN AND hi2.LGC = 1 "
* )
* })
*
* @SqlResultSetMappings({
* @SqlResultSetMapping(
* name = "mapping-find-item",
* entities= {
* @EntityResult(
* entityClass = "HTHotelItem",
* fields = {
* @FieldResult(name = "id", column="SN")
* }
* )
* }
* )
* })
*
*/
class HTHotelItem{
/** @Id @Column(type="integer") @GeneratedValue */
protected $id;
/** @name */
protected $name;
/** @city */
protected $city;
/** @url */
protected $url;
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata){
$metadata->addNamedNativeQuery(array(
'name' => 'find-hotel-item',
'query' => 'SELECT h FROM HTHotelItem h',
'resultSetMapping' => '\\Models\\Entities\\HTHotelItem'
));
}
function getId(){
return $this->id;
}
function getName(){
return $this->name;
}
function getCity(){
return $this->city;
}
function getUrl(){
return $this->url;
}
}
|
| Comment by dingdangjyz [ 14/Dec/12 ] |
|
@NamedNativeQueries query If we write the long SQL, it will be fault. NO error massage. |
| Comment by Fabio B. Silva [ 16/Dec/12 ] |
|
Can't reproduce, Could you try to change the attached test case and make it fail. Cheers |
| Comment by Benjamin Eberlei [ 24/Dec/12 ] |
|
The Doctrine\Common\Lexer is never used in combination with native queries, only with the Annotation Parser, so i cannot be the preg_split that causes your SQL to be broken. Or do you get annotation errors? Also what database are you using? maybe its related to the DBAL sql parsing? |
| Comment by dingdangjyz [ 31/Dec/12 ] |
|
I'm sorry my English is too bad. I think it's Doctrine \ is \ Lexer. PHP preg_split the function of the problem in this file. |
[DDC-2424] Removing an inherited entity via a delete cascade constraint does not remove the parent row Created: 02/May/13 Updated: 06/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.3.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Bruno Jacquet | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Mysql 5.1.66 / Symfony 2.2.1 |
||
| Description |
|
For a parent class: /** * @ORM\Entity * @ORM\Table(name="Base") * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorMap({"child1" = "Child1", "child2" = "Child2"}) */ and simple Child1 & Child2 entities. With another entity (let's call it ExternalEntity) having a bidirectional OneToOne relation owned by Child1: class Child1 extends Base { /** * @ORM\OneToOne(targetEntity="ExternalEntity", inversedBy="xxx") * @ORM\JoinColumn(onDelete="CASCADE", nullable=false) */ private theForeignKey; } Enough for the context. $em->remove(instanceOfExternalEntity); removes the ExternalEntity row and the Child1 row. But a dangling row in the Base table is still there for the now inexistent Child1 instance. Though, a manual delete of either the associated Child1 OR Base row and then the ExternalEntity works. The problem with the cascading deletion of the parent seems to be only present when deleting through a MYSQL cascading delete from another row which has a foreign key on a child. (Not tested with a foreign key on the parent though) |
| Comments |
| Comment by Benjamin Eberlei [ 04/May/13 ] |
|
Can you show the CREATE TABLE and FOREIGN KEY statements of all the tables involved? It seems the cascade of the foreign keys is not propagated between multiple tables? |
| Comment by Bruno Jacquet [ 06/May/13 ] |
|
CREATE TABLE Base (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; ALTER TABLE Child1 ADD CONSTRAINT FK_179B6E88E992F5A FOREIGN KEY (foreignKey) REFERENCES ExternalEntity (id) ON DELETE CASCADE; |
| Comment by Bruno Jacquet [ 06/May/13 ] |
|
The problem is that, the SQL model never explicitely tells the DB to delete the corresponding Base when Child1 gets removed. It looks like it is handled by the doctrine entity manager layer and not the actual DB engine (Base has no on delete cascade nor foreign key to its children). |
| Comment by Bruno Jacquet [ 06/May/13 ] |
|
Maybe using cascade={"remove"}
, instead of onDelete="CASCADE"
to force the cascading process to be handled by doctrine would workaround the bug... But I prefer to have my DB do the logic work as much as possible. |
[DDC-2147] Custom annotation in MappedSuperclass Created: 15/Nov/12 Updated: 07/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers, ORM |
| Affects Version/s: | 2.2.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | kluk | Assignee: | Marco Pivetta |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux 3.6.6-1.fc17.x86_64 |
||
| Attachments: |
|
| Description |
|
When you try use custom annotation in mappedsuperclass like here http://pastebin.com/YMxKvcLk and then i try get metadata for class i get this error |
| Comments |
| Comment by kluk [ 15/Nov/12 ] |
|
error log from orm:validate-schema |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
Copying from pastebin: use \Doctrine\ORM\Mapping as ORM; use \xxx\Doctrine\Annotation\Entity as re; use \xxx\Doctrine\Annotation\Forms as rf; use \Doctrine\Common\Collections; /** * @ORM\Entity */ class EventPicture extends \Picture { /** * @ORM\ManyToOne(targetEntity="Event", inversedBy="eventPicture") * @ORM\JoinColumn(name="FK_Event", referencedColumnName="id") */ protected $event; } use \Doctrine\ORM\Mapping as ORM; use \xxx\Doctrine\Annotation\Entity as re; use \xxx\Doctrine\Annotation\Forms as rf; use \Doctrine\Common\Collections; /** @ORM\MappedSuperclass */ class Picture extends \xxx\Doctrine\Entity\BaseEntity { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="IDENTITY") * @var type */ protected $id; /** * @ORM\Column(type="string",unique=true, nullable=false) * @rf\FileUpload(fileSize="php",uploadType="local",fieldName="link",formControl="FileUploadField",image=true) * */ protected $link; } kluk does this happen also with any other simple custom annotation? For example following:
/**
* @Annotation
* @Target({"PROPERTY","ANNOTATION"})
*/
final class Entity implements Annotation
{
/**
* @var string
*/
public $value;
}
|
| Comment by kluk [ 30/Jan/13 ] |
|
the same error when using simple annotation.
<?php
use \Doctrine\ORM\Mapping as ORM;
use \xxx\Doctrine\Annotation\Entity as re;
use \xxx\Doctrine\Annotation\Forms as rf;
use \Doctrine\Common\Collections;
/** @ORM\MappedSuperclass */
class Picture extends \xxx\Doctrine\Entity\BaseEntity {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
* @var type
*/
protected $id;
/**
* @ORM\Column(type="integer")
* @rf\SetClass({"class","hide"})
*/
public $value;
/**
* @ORM\Column(type="string",unique=true, nullable=true)
* @rf\FileUpload(fileSize="php",uploadType="local",fieldName="link",formControl="FileUploadField",image=true)
*
*/
protected $link;
}
When i remove $value , $picture from class everything goes ok.
/**
* INTERNAL:
* Adds a field mapping without completing/validating it.
* This is mainly used to add inherited field mappings to derived classes.
*
* @param array $fieldMapping
*
* @return void
*/
public function addInheritedFieldMapping(array $fieldMapping)
{
if(isset($fieldMapping['fieldName'])){
$this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping;
$this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName'];
$this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName'];
}
}
But i dont know if this fix can break another part of doctrine. |
| Comment by Benjamin Eberlei [ 04/May/13 ] |
|
Can you put the code of your annotations online? I can't seem to understand why this happens. |
| Comment by kluk [ 07/May/13 ] |
|
Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml namespace libs\Doctrine\Annotation\Entity; use Doctrine\Common\Annotations\Annotation; /** @Annotation */ class CustomMapping extends Annotation { /** * * @var string */ public $className; /** * * * @var IQueryable| string */ public $dataSource; } |
[DDC-2449] Amazon Redshift Support Created: 15/May/13 Updated: 15/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Kirill F | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Amazon Redshift |
||
| Description |
|
It would be nice to get doctrine compatible with Amazon Redshift. It uses a Postgres connector but there are some differences. I'm currently facing an issue with the primary id, in Redshift the generation of an id is different from Postgres and so I'm getting errors associated with generating an id. Here are some references that might be useful: Amazon Manual: |
[DDC-2035] XML Mapping : add attribute "length" for tag "id" Created: 20/Sep/12 Updated: 29/Sep/12 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Erik Müller | Assignee: | Fabio B. Silva |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux, Doctrine ORM 2.3.0, MySQL |
||
| Description |
|
XML mapping : <id name="id" type="string" length="16"/> Generate SQL : id varchar(255) not null
It's not possible with XML mapping to have : id varchar(16) not null
Because tag "id" doesn't support "length" attribute. |
| Comments |
| Comment by Fabio B. Silva [ 20/Sep/12 ] |
|
Hi Erik, The atribute "id" arealdy support "length" in the current doctrine version Which version are you using ? |
[DDC-1630] Get PersistentCollection::getDeleteDiff is empty when collection changes from 1 item to zero items Created: 31/Jan/12 Updated: 09/Feb/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Minor |
| Reporter: | Lee | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
Symfony2 |
||
| Attachments: |
|
| Comments |
| Comment by Steve Müller [ 09/Feb/12 ] |
|
Same problem here. I wanted to write some unit tests, checking the entity relations and ran into exactly the same problem. Maybe my code can provide some more information (Group entity is the owning side, role entity is the inverse side): WHAT DOES NOT WORK: /**
* Test ArrayCollection
*/
$group = new Group('Group Test');
$em->persist($group);
$em->flush();
$groups = new ArrayCollection();
$groups->add($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
/**
* Test PersistentCollection
*/
$em->persist($this->role);
$em->flush();
$groups = $this->role->getGroups();
$groups->removeElement($group); // first remove element before adding a new one
$group = new Group('Group Test 2');
$em->persist($group);
$em->flush();
$groups->add($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
WHAT WORKS: /**
* Test ArrayCollection
*/
$group = new Group('Group Test');
$em->persist($group);
$em->flush();
$groups = new ArrayCollection();
$groups->add($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
/**
* Test PersistentCollection
*/
$em->persist($this->role);
$em->flush();
$groups = $this->role->getGroups();
$group2 = new Group('Group Test 2');
$em->persist($group2);
$em->flush();
$groups->add($group2); // first adding a new element before removing one
$groups->removeElement($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
Hope this helps in any way... I tried figuring it out on my own but I am too drunk right now xD |
| Comment by Benjamin Eberlei [ 10/Feb/12 ] |
|
Thanks for the report, formatted it |
| Comment by Benjamin Eberlei [ 10/Feb/12 ] |
|
Which version is that btw? |
| Comment by Steve Müller [ 16/Feb/12 ] |
|
Occurs in version 2.1.6 |
| Comment by Benjamin Eberlei [ 20/Feb/12 ] |
|
If group is the owning side, why do you only set Role::$groups? This has to be the other way around or not? |
| Comment by Benjamin Eberlei [ 20/Feb/12 ] |
|
@Steve I cannot reproduce your issue. Attached is a test script. Your code is very weird btw, why are you getting and setting groups collection? It is passed by reference so you can just have something like $role->addGroup() and $role->removeGroup() and encapsulate the logic? Also your tests are pretty useless, you check if two variables which are the same reference to the same collection are the same. Which should always be true. @Lee Can you provide more details? I cant verify this without more details. |
| Comment by Alexander [ 09/Feb/13 ] |
|
Can anyone provide us with more feedback? |
[DDC-1494] Query results are overwritten by previous query. Created: 15/Nov/11 Updated: 09/Feb/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Minor |
| Reporter: | J | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3 + MySQL 5.5 |
||
| Attachments: |
|
| Description |
|
I am running a query that JOINs three tables, with a simple WHERE: $q = $em->createQuery("
SELECT cat, n, c
FROM Project_Model_NoticeCategory cat
JOIN cat.notices n
JOIN n.chapters c
WHERE
c.id = :chapter_id
");
When I do this: $q->setParameter('chapter_id', 1);
$a = $q->getResult();
$q->setParameter('chapter_id', 2);
$b = $q->getResult();
$b always has the wrong results. Running the following code: $q->setParameter('chapter_id', 1);
$a = $q->getResult();
$q->setParameter('chapter_id', 2);
$b = $q->getResult();
$z = $q->getArrayResult();
BUG Results: $b != $z (getArrayResult IS CORRECT, it refreshes the results) Note: $a==$b (which is wrong) Explanation: There is a chapter table, this has a many-to-many join to notices (these are meta info Data model: /** * @Entity * @Table(name="chapter") */ class Project_Model_Chapter { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** @Column(type="string") */ private $title; /** * @ManyToMany(targetEntity="Project_Model_Notice", mappedBy="chapters") */ private $notices; .... /lots of code snipped/ .... } /** * @Entity * @Table(name="notice") */ class Project_Model_Notice { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** @Column(type="string") */ private $title; /** * @ManyToMany(targetEntity="Project_Model_Chapter", inversedBy="notices") * @JoinTable(name="chapter_notice") */ private $chapters; /** * @ManyToOne(targetEntity="Project_Model_NoticeCategory", inversedBy="notices") */ private $notice_category; .... /lots of code snipped/ .... } /** * @Entity * @Table(name="notice_category") */ class Project_Model_NoticeCategory { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** @Column(type="string") */ private $title; /** * Bidirectional - One-To-Many (INVERSE SIDE) * * @OneToMany(targetEntity="Project_Model_Notice", mappedBy="notice_category", cascade={"persist", "remove"}) */ private $notices; .... /lots of code snipped/ .... } Data fixtures: $tools = new \Project_Model_NoticeCategory; $tools->setTitle('Tools'); $spanner = new \Project_Model_Notice; $spanner->setTitle('spanner'); $tools->addNotice($spanner); $drill = new \Project_Model_Notice; $drill->setTitle('power drill'); $tools->addNotice($drill); $this->em->persist($tools); $this->em->flush(); $tools = new \Project_Model_NoticeCategory; $tools->setTitle('Safety'); $gloves = new \Project_Model_Notice; $gloves->setTitle('gloves'); $tools->addNotice($gloves); $goggles = new \Project_Model_Notice; $goggles->setTitle('goggles'); $tools->addNotice($goggles); $this->em->persist($tools); $this->em->flush(); $chapter1 = new \Project_Model_Chapter; $chapter1->setTitle('Chapter 1'); $this->em->persist($chapter1); $chapter2 = new \Project_Model_Chapter; $chapter2->setTitle('Chapter 2'); $this->em->persist($chapter2); $chapter1->addNotice($spanner); $chapter1->addNotice($gloves); $chapter2->addNotice($spanner); $chapter2->addNotice($gloves); $chapter2->addNotice($drill); $chapter2->addNotice($goggles); // now persist and flush everything Initial investigation: I think it has something to do with HINT_REFRESH ? Stepping through: ObjectHydrator->_hydrateRow when it requests the Project_Model_Category from the unit of work, it |
| Comments |
| Comment by Benjamin Eberlei [ 15/Nov/11 ] |
|
Fixed formatting |
| Comment by Benjamin Eberlei [ 18/Nov/11 ] |
|
are you using result caching? |
| Comment by J [ 21/Nov/11 ] |
|
This is part of my bootstrap $config = new \Doctrine\ORM\Configuration(); $cache = new \Doctrine\Common\Cache\ArrayCache; $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // driver: schema $driver = $config->newDefaultAnnotationDriver( APPLICATION_PATH . '/models' ); $config->setMetadataDriverImpl($driver); |
| Comment by Benjamin Eberlei [ 15/Dec/11 ] |
|
Cannot reproduce it with the script attached. Can you try to modify this to fail or write your own testcase? |
| Comment by Benjamin Eberlei [ 15/Dec/11 ] |
|
Downgraded |
| Comment by Alexander [ 09/Feb/13 ] |
|
Please provide extra feedback. |
[DDC-2281] Validation against database-first generated xml requires that the column order within a composite primary key match the order the columns are in in mapping xml Created: 06/Feb/13 Updated: 09/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.3.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Minor |
| Reporter: | Aaron Moore | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In using a database-first approach utilizing orm:convert-mapping to generate xml, the validation and schema-tool reports that my composite primary key (ex. Columns A, C, B) be dropped and added in the order in which the mapping appears in the xml (ex. Columns A, B, C). These columns are not auto-increment and are simply a mixture of int and varchar. |
| Comments |
| Comment by Benjamin Eberlei [ 09/May/13 ] |
|
Is the composite key a mix of association and field types? |
| Comment by Aaron Moore [ 09/May/13 ] |
|
I'm trying to remember the usage as it was a short term project but I believe it is. For example a user has a userid. The table in question might have a primary key consisting of the userid and an int representing a year.. |