Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Unexpected transaction commit on query.getResultList()

Thanks, Gordon!

That's exactly what I needed.

On Fri, May 8, 2009 at 7:22 AM, Gordon Yorke <gordon.yorke@xxxxxxxxxx> wrote:
> The name of the method being called may suggest a commit but actually this
> code just writes the current changes to the database but leaves the
> transaction active.  This is done once there are changes to the managed
> objects to ensure that your query will be resolved against those changes.
>  If you do not want this behaviour you can set your EntityManager or Query
> flush mode (setFlushMode) to FlushModeType.COMMIT.
> --Gordon
>
> Mike Kienenberger wrote:
>>
>> I'm using EclipseLink 1.0.2.   I have an update transaction started,
>> and I performed a select query.getResultList() call, and it attempted
>> to commit my transaction!  I wasn't expecting that behavior -- is this
>> a bug in Eclipselink or a feature of JPA?
>>
>> When I was previously working with ToplinkEssentials, I noticed that
>> there was both a read and write connection pool, so I would have
>> thought that read-only queries would have used a separate connection
>> since EclipseLink is based off the same source.
>>
>> Thanks for your input.
>> -Mike
>>
>>       at
>> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1370)
>>       at
>> org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:300)
>>       at
>> org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:384)
>>       at
>> org.eclipse.persistence.internal.jpa.EJBQueryImpl.performPreQueryFlush(EJBQueryImpl.java:936)
>>       at
>> org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:378)
>>       at
>> org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:517)
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Back to the top