[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] autocommit problem
|
By default EclipseLink uses a read connection pool to process read queries
until a flush or data modification query (or locking query) has been
executed. A DataModifyQuery would can a transaction to start, but a
ValueReadQuery does not. You can begin a transaction yourself through
getUnitOfWork().beginEarlyTransaction().
Leon Derks-2 wrote:
>
> When I test the persistImageInfoIntoImageLibrary method, I noticed it
> also works without beginning a transaction.
>
> ImageInfo imageInfo = getImageInfo();
> imageDAO.persistImageInfoIntoImageLibrary(imageInfo);
>
> The image is persisted in the table and I didn't started a transaction.
> How is this possible?
>
> Can someone explain this to me?
> Leon
>
>
> Leon Derks wrote:
>> I want to store an image into another db schema, using a stored
>> function call.
>>
>> I do this by getting the ActiveSession() from my EntityManager, see
>> the Java code below:
>> In the logging I see the function is executed in eclipselink:
>>
>> The problem is that the image is already stored into the table, before
>> the transaction has committed.
>> So when I use pl/sql developer and view the table I see that the image
>> is stored without committing the transaction..
>>
>> The stored function call has no autonomous transaction. So how is this
>> possible?
>> Does the getActiveSession() has an autocommit?
>>
>>
>> JAVA CODE:
>> public ImageInfo persistImageInfoIntoImageLibrary(ImageInfo imageInfo) {
>> StoredFunctionCall functionCall = new StoredFunctionCall();
>> functionCall.setProcedureName("til.cil_api.create_image");
>> functionCall.addNamedArgument("p_image_id");
>> functionCall.addNamedArgument("p_image_type_id");
>> functionCall.addNamedArgument("p_collection_id");
>> functionCall.addNamedArgument("p_description");
>>
>> ValueReadQuery query = new ValueReadQuery(functionCall);
>>
>> query.addArgument("p_image_id");
>> query.addArgument("p_image_type_id");
>> query.addArgument("p_collection_id");
>> query.addArgument("p_description");
>>
>> List args = new ArrayList();
>> args.add(null);
>> args.add(GuideControlConfiguration.getImageTypeId());
>> args.add(GuideControlConfiguration.getImageCollectionId());
>> args.add(imageInfo.getVisualElementId());
>> functionCall.setResult("function_result", Integer.class);
>>
>> Integer tangeloImageId = (Integer)
>> getActiveSession().executeQuery(query, args);
>> }
>>
>> private Session getActiveSession() {
>> return ((JpaEntityManager) getEntityManager()).getActiveSession();
>> }
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/autocommit-problem-tp20149191p20188347.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.