<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 25 10:03:42 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-881/DDC-881.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-881] DDC-117: Linked Objects with composite key</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-881</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I&apos;m currently playing around with &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-117&quot; title=&quot;Allow @Id on @ManyToOne fields&quot;&gt;&lt;del&gt;DDC-117&lt;/del&gt;&lt;/a&gt;. I came across a general&lt;br/&gt;
problem which occurs with relations.&lt;/p&gt;

&lt;p&gt;Given the following two classes, should a&lt;br/&gt;
@OneToOne/@OneToMany/@ManyToMany relation consider a composite ID or is&lt;br/&gt;
that not planned with &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-117&quot; title=&quot;Allow @Id on @ManyToOne fields&quot;&gt;&lt;del&gt;DDC-117&lt;/del&gt;&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;In the past, we assumed that an object is identified unique with an @Id&lt;br/&gt;
column. However, if we support composite keys, an object needs to be&lt;br/&gt;
identified by two or more columns, which we need to take into&lt;br/&gt;
consideration when building queries and foreign keys. Is that correct?&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;/**
 * @Entity
 */

class Document {
	/**
	 * @Id
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
	 * @GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;

	/**
	 * @Id
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $version;

	/**
	 * @ManyToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;Content&quot;&lt;/span&gt;)
	 * Enter description here ...
	 * @&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; unknown_type
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $content;
}

/**
 * @Entity
 */
class Content {
	/**
	 * @Id
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
	 * @GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;

	/**
	 * @Id
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $version;

	/**
	 * @ManyToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;Document&quot;&lt;/span&gt;)
	 */

	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $document;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I know this might become a bit tricky, because $content refers to a&lt;br/&gt;
single instance of Content, but we actually need two columns to identify&lt;br/&gt;
it. That&apos;s how it looks if generated with Doctrine2 (&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-117&quot; title=&quot;Allow @Id on @ManyToOne fields&quot;&gt;&lt;del&gt;DDC-117&lt;/del&gt;&lt;/a&gt;):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;mysql&amp;gt; describe Document;
+------------+---------+------+-----+---------+-------+
| Field      | Type    | Null | Key | Default | Extra |
+------------+---------+------+-----+---------+-------+
| id         | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| version    | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| content_id | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | YES  | MUL | NULL    |       |
+------------+---------+------+-----+---------+-------+
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;mysql&amp;gt; describe Content;
+-------------+---------+------+-----+---------+-------+
| Field       | Type    | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+-------+
| id          | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| version     | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| document_id | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | YES  | MUL | NULL    |       |
+-------------+---------+------+-----+---------+-------+
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;However, to make my example work, the tables would need to look the&lt;br/&gt;
following:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;mysql&amp;gt; describe Content;
+------------------+---------+------+-----+---------+-------+
| Field            | Type    | Null | Key | Default | Extra |
+------------------+---------+------+-----+---------+-------+
| id               | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| version          | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| document_id      | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | YES  | MUL | NULL    |       |
| document_version | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | YES  |     | NULL    |       |
+------------------+---------+------+-----+---------+-------+
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;mysql&amp;gt; describe Document;
+-----------------+---------+------+-----+---------+-------+
| Field           | Type    | Null | Key | Default | Extra |
+-----------------+---------+------+-----+---------+-------+
| id              | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| version         | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | NO   | PRI | NULL    |       |
| content_id      | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | YES  | MUL | NULL    |       |
| content_version | &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(11) | YES  |     | NULL    |       |
+-----------------+---------+------+-----+---------+-------+
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;It would be nice if we could discuss this one, as I feel it is important for an ORM.&lt;/p&gt;</description>
                <environment></environment>
            <key id="12121">DDC-881</key>
            <summary>DDC-117: Linked Objects with composite key</summary>
                <type id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/subtask_alternate.png">Sub-task</type>
                    <parent id="10344">DDC-117</parent>
                        <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="romanb">Roman S. Borschel</assignee>
                                <reporter username="felicitus">Timo A. Hummel</reporter>
                        <labels>
                    </labels>
                <created>Thu, 18 Nov 2010 03:20:26 +0000</created>
                <updated>Sun, 2 Jan 2011 06:05:12 +0000</updated>
                    <resolved>Sun, 2 Jan 2011 06:05:12 +0000</resolved>
                                            <fixVersion>2.1</fixVersion>
                                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14775" author="beberlei" created="Thu, 18 Nov 2010 03:25:13 +0000"  >&lt;p&gt;Hm i think this issue appears becaues &quot;version&quot; in your mapping is defined twice in the &quot;Content&quot; entity.&lt;/p&gt;

&lt;p&gt;You have rename the join column and it should work. Howevr ClassMetadata should throw an exception.&lt;/p&gt;</comment>
                    <comment id="14776" author="felicitus" created="Thu, 18 Nov 2010 03:28:22 +0000"  >&lt;p&gt;So in theory, doctrine should handle my example with &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-117&quot; title=&quot;Allow @Id on @ManyToOne fields&quot;&gt;&lt;del&gt;DDC-117&lt;/del&gt;&lt;/a&gt;? Will try that out later with unique field names and report back. If that would work already, this would be amazing!&lt;/p&gt;</comment>
                    <comment id="14778" author="beberlei" created="Thu, 18 Nov 2010 03:34:19 +0000"  >&lt;p&gt;btw your mapping is somewhat wrong. you cannot have two @ManyToOne that connect the same two entities with each other. One has to be @OneToMany&lt;/p&gt;</comment>
                    <comment id="14806" author="felicitus" created="Wed, 24 Nov 2010 10:30:35 +0000"  >&lt;p&gt;Benjamin, I finally had time to check out more things. In fact, Doctrine with &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-117&quot; title=&quot;Allow @Id on @ManyToOne fields&quot;&gt;&lt;del&gt;DDC-117&lt;/del&gt;&lt;/a&gt; completely ignores multiple foreign keys.&lt;/p&gt;

&lt;p&gt;Even if I replace @ManyToOne with @OneToMany, and version with fversion in Content, Doctrine still only creates a reference (and columns!) with content_id only. I would have expected that that I find at least content_id and content_version within the Document table&lt;/p&gt;

&lt;p&gt;I also tried to specify mappedBy=&quot;document,version&quot;, but this also didn&apos;t work.&lt;/p&gt;

&lt;p&gt;So again the question: Is my initial example meant to be possible with &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-117&quot; title=&quot;Allow @Id on @ManyToOne fields&quot;&gt;&lt;del&gt;DDC-117&lt;/del&gt;&lt;/a&gt;, or is it not?&lt;/p&gt;
</comment>
                    <comment id="14807" author="felicitus" created="Wed, 24 Nov 2010 11:11:13 +0000"  >&lt;p&gt;I just created a better test.&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;User.php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&amp;lt;?php
/**
 * @Entity
 */
class User {
	/**
	 * @Id
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
	 * @GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;
	
	/**
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $name;
	
	/**
	 * @OneToMany(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;PhoneNumber&quot;&lt;/span&gt;,mappedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;id&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $phoneNumbers;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;PhoneNumber.php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&amp;lt;?php
/**
 * @Entity
 */
class PhoneNumber {
	/**
	 * @Id
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;
	
	/**
	 * @Id
	 * @ManyToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;User&quot;&lt;/span&gt;,cascade={&lt;span class=&quot;code-quote&quot;&gt;&quot;all&quot;&lt;/span&gt;})
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $user;
	
	/**
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $phonenumber;
	
	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setId ($id) {
		$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;id = $id;
	}
	
	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUser (User $user) {
		$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;user = $user;
	}
	
	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setPhoneNumber ($phoneNumber) {
		$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;phonenumber = $phoneNumber;
	}
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;PhoneCall.php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&amp;lt;?php 
/**
 * @Entity
 */
class PhoneCall {
	/**
	 * @Id
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
	 * @GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;
	
	/**
	 * @OneToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;PhoneNumber&quot;&lt;/span&gt;,cascade={&lt;span class=&quot;code-quote&quot;&gt;&quot;all&quot;&lt;/span&gt;})
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $phonenumber;
	
	/**
	 * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;,nullable=&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)
	 */
	&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $callDate;
	
	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setPhoneNumber (PhoneNumber $phoneNumber) {
		$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;phonenumber = $phoneNumber;
	}
	
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is a very basic mapping example, where one user may have many phone numbers. Also we have a PhoneCall entity which stores the call made. Since a single phone number isn&apos;t just identified by id, but also by user_id, Doctrine should create two fields in PhoneCall for that relation: phonenumber_id and phonenumber_user_id, so that we can retrieve the PhoneNumber object by PhoneCall&apos;s phonenumber property.&lt;/p&gt;

&lt;p&gt;If you agree that my example should be working, I&apos;m willing to write a test case and see if I can contribute code to make that happen.&lt;/p&gt;</comment>
                    <comment id="14808" author="felicitus" created="Wed, 24 Nov 2010 12:05:12 +0000"  >&lt;p&gt;I&apos;m preparing a real-world test script; no need to respond for now.&lt;/p&gt;</comment>
                    <comment id="14837" author="felicitus" created="Thu, 25 Nov 2010 06:13:40 +0000"  >&lt;p&gt;As promised, here&apos;s the real-world test script. Note that I adjusted the code for the example entities due to &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-891&quot; title=&quot;DDC-117: No sequence generation with composite foreign key&quot;&gt;DDC-891&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;Test Script&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;/* Create two test users: albert and alfons */
$albert = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; User;
$albert-&amp;gt;setName(&lt;span class=&quot;code-quote&quot;&gt;&quot;albert&quot;&lt;/span&gt;);
$em-&amp;gt;persist($albert);

$alfons = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; User;
$alfons-&amp;gt;setName(&lt;span class=&quot;code-quote&quot;&gt;&quot;alfons&quot;&lt;/span&gt;);
$em-&amp;gt;persist($alfons);

/* Assign two phone numbers to each user */
$phoneAlbert1 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PhoneNumber();
$phoneAlbert1-&amp;gt;setUser($albert);
$phoneAlbert1-&amp;gt;setId(1);
$phoneAlbert1-&amp;gt;setPhoneNumber(&lt;span class=&quot;code-quote&quot;&gt;&quot;albert home: 012345&quot;&lt;/span&gt;);
$em-&amp;gt;persist($phoneAlbert1);

$phoneAlbert2 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PhoneNumber();
$phoneAlbert2-&amp;gt;setUser($albert);
$phoneAlbert2-&amp;gt;setId(2);
$phoneAlbert2-&amp;gt;setPhoneNumber(&lt;span class=&quot;code-quote&quot;&gt;&quot;albert mobile: 67890&quot;&lt;/span&gt;);
$em-&amp;gt;persist($phoneAlbert2);

$phoneAlfons1 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PhoneNumber();
$phoneAlfons1-&amp;gt;setId(1);
$phoneAlfons1-&amp;gt;setUser($alfons);
$phoneAlfons1-&amp;gt;setPhoneNumber(&lt;span class=&quot;code-quote&quot;&gt;&quot;alfons home: 012345&quot;&lt;/span&gt;);
$em-&amp;gt;persist($phoneAlfons1);

$phoneAlfons2 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PhoneNumber();
$phoneAlfons2-&amp;gt;setId(2);
$phoneAlfons2-&amp;gt;setUser($alfons);
$phoneAlfons2-&amp;gt;setPhoneNumber(&lt;span class=&quot;code-quote&quot;&gt;&quot;alfons mobile: 67890&quot;&lt;/span&gt;);
$em-&amp;gt;persist($phoneAlfons2);

/* We call alfons and albert once on their mobile numbers */
$call1 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PhoneCall();
$call1-&amp;gt;setPhoneNumber($phoneAlfons2);
$em-&amp;gt;persist($call1);

$call2 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PhoneCall();
$call2-&amp;gt;setPhoneNumber($phoneAlbert2);
$em-&amp;gt;persist($call2);

$em-&amp;gt;flush();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;During the flush, Doctrine fails with&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Integrity constraint violation: 1062 Duplicate entry &apos;2&apos; &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; key &apos;PhoneCall_phonenumber_id_uniq&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;because Doctrine does not create the composite primary key (which is id and user_id) as foreign key (Doctrine only adds  id).&lt;/p&gt;</comment>
                    <comment id="15048" author="beberlei" created="Tue, 28 Dec 2010 16:34:58 +0000"  >&lt;p&gt;The problem here is your @OneToOne relation. It implicitly sets a unique index. The primary key generated by your mapping is ok.&lt;/p&gt;

&lt;p&gt;Try to modify your code stating @OneToOne(unique=false)&lt;/p&gt;

&lt;p&gt;Additionally you have to specifiy the join columns. You are using the default, which obviously doesn&apos;t work for a composite approach (that is not default):&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;/**
 * @Entity
 */
class DDC881PhoneCall
{

    /**
     * @Id
     * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
     * @GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;
    /**
     * @OneToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;DDC881PhoneNumber&quot;&lt;/span&gt;,cascade={&lt;span class=&quot;code-quote&quot;&gt;&quot;all&quot;&lt;/span&gt;})
     * @JoinColumns({
     *  @JoinColumn(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;phonenumber_id&quot;&lt;/span&gt;, referencedColumnName=&lt;span class=&quot;code-quote&quot;&gt;&quot;id&quot;&lt;/span&gt;),
     *  @JoinColumn(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;user_id&quot;&lt;/span&gt;, referencedColumnName=&lt;span class=&quot;code-quote&quot;&gt;&quot;user_id&quot;&lt;/span&gt;)
     * })
     */
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $phonenumber;
    /**
     * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;,nullable=&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $callDate;

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setPhoneNumber(DDC881PhoneNumber $phoneNumber)
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;phonenumber = $phoneNumber;
    }

}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That would be the right approach if there were not a bug in SchemaTool i need to fix for this to work &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                    <comment id="15052" author="beberlei" created="Wed, 29 Dec 2010 04:31:50 +0000"  >&lt;p&gt;This is a really tricky issue, we need to think about it a little longer.&lt;/p&gt;</comment>
                    <comment id="15096" author="beberlei" created="Sun, 2 Jan 2011 06:05:12 +0000"  >&lt;p&gt;Fixed.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>