<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Fri May 24 03:35:47 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-451/DDC-451.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-451] Add GUID/UUID Id Generator</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-451</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;We should add an IdGenerator that facilitates the DB Vendors UUID()/GUID() generation facilities.&lt;/p&gt;

&lt;p&gt;Although these IdGenerators take more space compared to other Generators there are use-cases which can be only solved with this kind of Id Generator.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11101">DDC-451</key>
            <summary>Add GUID/UUID Id Generator</summary>
                <type id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/newfeature.png">New Feature</type>
                                <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="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="beberlei">Benjamin Eberlei</reporter>
                        <labels>
                    </labels>
                <created>Sat, 20 Mar 2010 14:04:48 +0000</created>
                <updated>Mon, 13 Aug 2012 20:27:11 +0000</updated>
                    <resolved>Mon, 12 Mar 2012 12:04:35 +0000</resolved>
                            <version>2.0-ALPHA4</version>
                                <fixVersion>2.3</fixVersion>
                                <component>ORM</component>
                        <due></due>
                    <votes>3</votes>
                        <watches>6</watches>
                        <comments>
                    <comment id="12411" author="guilhermeblanco" created="Sat, 20 Mar 2010 16:52:46 +0000"  >&lt;p&gt;Here is a basic GUID generator.&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;class Guid
{
    /**
     * Generate a GUID
     *
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; string
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; function generate()
    {
        $cpuname     = getenv(&apos;COMPUTERNAME&apos;);
        $address     = isset($_SERVER[&apos;SERVER_ADDR&apos;]) ? @$_SERVER[&apos;SERVER_ADDR&apos;] : uniqid(hash(&lt;span class=&quot;code-quote&quot;&gt;&quot;md5&quot;&lt;/span&gt;, time()), &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;) . time();
        $address     = (trim($cpuname) == &apos;&apos; ? crypt(uniqid(rand(), &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)) : $cpuname) . &apos;/&apos; . $address;
        $milisecs        = microtime();
        $randomLong  = (rand(0, 1))? &apos;-&apos;:&apos;&apos;;
        $randomLong .= rand(1000, 9999).rand(1000, 9999).rand(1000, 9999).rand(100, 999).rand(100, 999);
        
        $string = $address . &apos;:&apos; . $milisecs . &apos;:&apos; . $randomLong;
        $hashString = strtoupper(md5($string));
        
        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; substr($hashString, 0, 8).&apos;-&apos;.substr($hashString, 8, 4).&apos;-&apos;.substr($hashString, 12, 4).&apos;-&apos;.substr($hashString, 16, 4).&apos;-&apos;.substr($hashString, 20);
    }
    
    
    /**
     * Verifies &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; a string is a valid Guid generated acording to &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; class
     *
     * @param string $guid Guid to be analyzed
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;boolean&lt;/span&gt;
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; function match($guid)
    {
        
        $match = preg_match(&lt;span class=&quot;code-quote&quot;&gt;&quot;/^([A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12})$/&quot;&lt;/span&gt;, $guid);
        
        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $match;
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="12921" author="andyajadeh" created="Wed, 12 May 2010 05:34:25 +0000"  >&lt;p&gt;I agree, there are some application features that can only be done with GUID.&lt;/p&gt;</comment>
                    <comment id="13690" author="steffenvogel" created="Sun, 25 Jul 2010 08:32:38 +0000"  >&lt;p&gt;Oh, thats a quite simple implementation of a UUID/GUID generator.&lt;/p&gt;

&lt;p&gt;I would prefer something like this:&lt;br/&gt;
&lt;a href=&quot;http://github.com/volkszaehler/volkszaehler.org/blob/master/backend/lib/Util/UUID.php&quot; class=&quot;external-link&quot;&gt;http://github.com/volkszaehler/volkszaehler.org/blob/master/backend/lib/Util/UUID.php&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Its a RFC2144 compatible implementation for UUIDs&lt;/p&gt;</comment>
                    <comment id="16223" author="gedrox" created="Wed, 27 Jul 2011 13:46:17 +0000"  >&lt;p&gt;Here is complete code how to do this - &lt;a href=&quot;http://ranskills.wordpress.com/2011/05/26/how-to-add-a-custom-id-generation-strategy-to-doctrine-2-0/&quot; class=&quot;external-link&quot;&gt;http://ranskills.wordpress.com/2011/05/26/how-to-add-a-custom-id-generation-strategy-to-doctrine-2-0/&lt;/a&gt;.&lt;/p&gt;</comment>
                    <comment id="16912" author="maartendekeizer" created="Wed, 23 Nov 2011 22:04:39 +0000"  >&lt;p&gt;A couple of months ago I created 2 pull requests for this feature (&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/127&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/127&lt;/a&gt; and &lt;a href=&quot;https://github.com/doctrine/dbal/pull/58&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/58&lt;/a&gt;). It would be nice if the feature is in the next Doctrine release.&lt;/p&gt;</comment>
                    <comment id="17557" author="beberlei" created="Mon, 12 Mar 2012 12:04:35 +0000"  >&lt;p&gt;Implemented&lt;/p&gt;</comment>
                    <comment id="17558" author="beberlei" created="Mon, 12 Mar 2012 12:06:08 +0000"  >&lt;p&gt;Details: This works with Database provided GUID functionality only for now, the UUID Generator uses the AbstractPlatform#getGuidSqlExpression() function and a SELECT clause to fetch a new guid. A next step might be to add a Platform#supportsGuidGeneration() flag and otherwise fallback to a PHP based generation.&lt;/p&gt;

&lt;p&gt;The Id generator in the ORM is pre insert, which makes this very awesome &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="18473" author="marijn" created="Tue, 7 Aug 2012 12:43:42 +0000"  >&lt;p&gt;There is a &lt;a href=&quot;https://github.com/ramsey/uuid&quot; class=&quot;external-link&quot;&gt;nice implementation&lt;/a&gt; out there with proper UUID generation and a DBAL datatype.&lt;/p&gt;
</comment>
                    <comment id="18474" author="beberlei" created="Tue, 7 Aug 2012 13:28:06 +0000"  >&lt;p&gt;starting with 2.3 there are custom id generators and you can do whatever you want. There is also a UUID/GUID type in 2.3 that is using the appropriate vendor database functions to generate those values.&lt;/p&gt;</comment>
                    <comment id="18487" author="holtkamp" created="Mon, 13 Aug 2012 02:54:34 +0000"  >&lt;blockquote&gt;
&lt;p&gt; There is also a UUID/GUID type in 2.3 that is using the appropriate vendor database functions to generate those values.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;So how would one be able to use this UUID/GUID? Would it be required for the column to be tagged as a @Id and @GeneratedValue with GUID strategy? I would like to have a random string generated which does not act as @Id within Doctrine... The text quoted suggests that it should work out of the box by setting the column type to &apos;guid&apos;, which it does not (2.3.0-RC1).&lt;/p&gt;

&lt;p&gt;Simply setting the column type to &apos;guid&apos; does not trigger the database to generate an ID when INSERTing a row...&lt;/p&gt;</comment>
                    <comment id="18488" author="ocramius" created="Mon, 13 Aug 2012 08:12:29 +0000"  >&lt;p&gt;I&apos;m not sure about PHP&apos;s case sensitivity, but as of &lt;a href=&quot;https://github.com/doctrine/doctrine2/blob/00a5f185444fb5d7c84e445d9ea6d6a68e087f98/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php#L310&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/blob/00a5f185444fb5d7c84e445d9ea6d6a68e087f98/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php#L310&lt;/a&gt; I think you should try with &quot;UUID&quot; (uppercase)&lt;/p&gt;</comment>
                    <comment id="18495" author="holtkamp" created="Mon, 13 Aug 2012 12:03:31 +0000"  >&lt;p&gt;Marco, it is indeed &apos;UUID&apos;, but this seems not to kick in when there is no @Id annotation used. I want to use it to come up with an identifier for an Order. It is not a primary key at database level or something like that. I was just wondering whether this new functionality can be used like that. I get the feeling it is not intended to be used like this: &lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;/**
 * Unique Order identifier that acts as reference for an Order even when multiple databases are involved
 * 
 * @var string
 * @ORM\Column(name=&quot;order_identifier&quot;, type=&quot;string&quot;, unique=true)
 * @ORM\GeneratedValue(strategy=&quot;UUID&quot;)
 */
protected $_orderIdentifier;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="18498" author="beberlei" created="Mon, 13 Aug 2012 13:53:27 +0000"  >&lt;p&gt;Well it is an ID generator. So it has to be with @Id.&lt;/p&gt;</comment>
                    <comment id="18499" author="holtkamp" created="Mon, 13 Aug 2012 15:50:40 +0000"  >&lt;p&gt;Well, yes, that was my question and that is now answered, thanks. &lt;/p&gt;

&lt;p&gt;It would be nice though to have UUID generation functionality available for non-database specific IDs as well. For instance for:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;user account activation tokens&lt;/li&gt;
	&lt;li&gt;payment references&lt;/li&gt;
	&lt;li&gt;invoice reference, etc.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This is now something that has to be implemented at the applciation level. But since we have these generators available, why not re-use it. By adding a @Id annotation, it becomes part of a composite key, which is not the purpose. Maybe I&apos;ll dive into the code and see whether this is possible.&lt;/p&gt;</comment>
                    <comment id="18500" author="beberlei" created="Mon, 13 Aug 2012 18:03:51 +0000"  >&lt;p&gt;it is available, just take a look at the code.&lt;/p&gt;</comment>
                    <comment id="18501" author="holtkamp" created="Mon, 13 Aug 2012 19:08:40 +0000"  >&lt;blockquote&gt;&lt;p&gt;Well it is an ID generator. So it has to be with @Id.&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;p&gt;it is available, just take a look at the code.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Mmm, now I am confused, I think we are mis-communicating. &lt;/p&gt;

&lt;p&gt;Maybe using less text and more descriptive examples:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;is it possible to use Database GUID functionality
	&lt;ul&gt;
		&lt;li&gt;without using the @Id annotations, to generate values for Entity properties that are not a primary key?&lt;/li&gt;
		&lt;li&gt;note that this Entity unique reference would exist next to a property that does have the @Id annotation&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Attempt 1:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;/**
 * The Order ID used at database level, which does NOT have any meaning within our domain, solely at database level
 *
 * @var integer
 * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy=&quot;IDENTITY&quot;)
 * @ORM\SequenceGenerator(sequenceName=&quot;orders_id_seq&quot;)
 */
protected $_id;

/**
 * The Order reference used at domain level, which DOES have meaning in our domain
 * Typically used to report in emails, printed on Invoices, etc
 *
 * @var string
 * @ORM\Column(name=&quot;order_identifier&quot;, type=&quot;guid&quot;)
 */
protected $_orderIdentifier;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;



&lt;p&gt;Attempt 2:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;/**
 * The Order ID used at database level, which does NOT have meaning within our domain, solely at database level
 *
 * @var integer
 * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy=&quot;IDENTITY&quot;)
 * @ORM\SequenceGenerator(sequenceName=&quot;orders_id_seq&quot;)
 */
protected $_id;

/**
 * The Order reference used at domain level, which DOES have meaning in our domain
 * Typically used to report in emails, printed on Invoices, etc
 *
 * @var string
 * @ORM\Column(name=&quot;order_identifier&quot;, type=&quot;string&quot;, unique=true)
 * @ORM\GeneratedValue(strategy=&quot;UUID&quot;)
 */
protected $_orderIdentifier;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Based on Benjamin&apos;s first answer I guess that this is not possible. Point is, the second answer indicates that it is possible &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/wink.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;. What is it?&lt;/p&gt;

&lt;p&gt;Also note that in Attempt 2, the @GeneratedValue annotation on the second property interferes with the ID generation of the Entity defined at the first property. This is probably to realize composite keys, but can result in unexpected behavior since it replaces the way the primary key is generated?&lt;/p&gt;
</comment>
                    <comment id="18502" author="beberlei" created="Mon, 13 Aug 2012 20:27:11 +0000"  >&lt;p&gt;Well @GeneratedValue Only works with @Id as I said. But there are low level APIs that you can look up in the UuidGenerator Strategy to use for something like this.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>