I'd like to say it's just an Oracle problem.  I wouldn't think it'd effect 
MySQL as it doesn't use sequences and I don't think this code gets touched. 
 I have a friend who's also using ZF2+Doctrine2 and doesn't have any 
complaints while on MySQL.   I don't have an environment to test with MySQL 
 (ok, I'm too lazy to set all this up on my own server) at the moment. 

Wish I had some time at home to run these tests for you.  My 19mo old 
consume any/all of my 'Geek Time'. :( 

On Tuesday, March 11, 2014 9:16:26 PM UTC-4, Marco Pivetta wrote:
>
> Hey Timothy,
>
> I thought I saw a bug from you about Oracle+D2, so I went back looking for 
> it :-)
>
> Could you please verify if this behavior is just Oracle-specific or if 
> mysql/sqlite/pgsql are also affected?
>
> Cheers,
>
> Marco Pivetta 
>
> http://twitter.com/Ocramius      
>
> http://ocramius.github.com/
>  
>
> On 4 March 2014 15:24, Timothy Lorens <[email protected] <javascript:>>wrote:
>
>> I was having some issues persisting associated records to our Oracle 
>> database.  The primary/parent entity was configured in the mapper to use a 
>> SEQUENCE.   It seems as if the SequenceGenerator was returning an improper 
>> sequence ID and Doctrine kept throwing an exception that the primary ID 
>> wasn't set on the associated record (or something to that nature)
>>
>> After some debugging and SQL logging.  I noticed that the parent ID for 
>> the associated entities was off by 1.  
>>
>>     public function generate(EntityManager $em, $entity)
>>     {
>>         if ($this->_maxValue === null || $this->_nextValue == 
>> $this->_maxValue) {
>>             // Allocate new values
>>             $conn = $em->getConnection();
>>             $sql  = 
>> $conn->getDatabasePlatform()->getSequenceNextValSQL($this->_sequenceName);
>>
>>             $this->_nextValue = (int)$conn->fetchColumn($sql);
>>             $this->_maxValue  = $this->_nextValue + 
>> $this->_allocationSize;
>>         }
>>
>>         return ++$this->_nextValue;
>>     }
>>
>> I didn't get too involved in figuring out exactly how this function 
>> worked.  But by incrementing _nextValue prior to returning it seems to have 
>> solved the problem.  
>>
>> If this isn't a bug with Doctrine 2 working with Oracle, Could someone 
>> please shed some light the issue of why the returned ID is 1 less than the 
>> parent ID inserted into the database.
>>
>> Setting *allocation-size* and *initial-value* didn't seem to change this 
>> behavior. 
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to