33 words

Issue #31 - Unexpected exception (Error 990) - Merge with no Transaction

BugVersion: Priority: NormalStatus: FixedReplies: 1
#1
2011-02-21 03:29

I am frequently having an error when merging a detached object outside of a transaction. (Is this allowed? I am not trying to modify the object, just read data from it.)

Here is a test case:

package com.experiments;
 
import javax.persistence.*;
import java.util.HashMap;
 
public class ErrorTest {
    public static void main(String[] args) throws Exception {
 
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("javax.persistence.jdbc.user", "xxxxx");
        map.put("javax.persistence.jdbc.password", "xxxxxx");
        final EntityManagerFactory emf =
            Persistence.createEntityManagerFactory("objectdb://xxxxxx/test.odb", map);
 
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        A a = new A("first version");
        em.persist(a);
        em.getTransaction().commit();
        em.close();
 
        em = emf.createEntityManager();
        em.getTransaction().begin();
        em.merge(a).setValue("second version");
        em.getTransaction().commit();
        em.close();
 
        em = emf.createEntityManager();
        a = em.merge(a);
        System.out.println(a.getValue());
        em.close();
 
    }
 
    @Entity
    public static class A {
        @Id
        @GeneratedValue
        Long id;
 
        String value;
 
        A(String value) {
            this.value = value;
        }
 
        public String getValue() {
            return value;
        }
 
        public void setValue(String value) {
            this.value = value;
        }
    }
}

 

Here is the error:

Exception in thread "main" [ObjectDB 2.0.5_03] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) Client VM 1.6.0_18 (on Windows 7 6.1).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: com.objectdb.o._IllegalArgumentException: Attempt to modify an object with no active transaction when NontransactionalWrite is disabled: com.fastmodel.fastplan.db.experiments.ErrorTest$A#64
[ObjectDB 2.0.5_03] java.lang.IllegalArgumentException
Attempt to modify an object with no active transaction when NontransactionalWrite is disabled: com.fastmodel.fastplan.db.experiments.ErrorTest$A#64 (error 635)
at com.objectdb.jpa.EMImpl.merge(EMImpl.java:428)
at com.experiments.ErrorTest.main(ErrorTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

ObjectDB always fails for this use case. I can make the code work by beginning a transaction in the last step. But I think this should be allowed. Let me know. Thanks.

Carl

FastModel
FastModel's picture
Joined on 2011-02-07
User Post #4
#2
2011-02-21 11:13

Thank you for your report. Please try version  2.0.5_04 - in which NonTransactionalWrite is enabled by default.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #136

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel