Problem with byte arrays in JDO - internal exception

#1

This code generates an internal exception:

package spiffy.test;

import java.util.List;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import spiffy.test.model.Example;

/**
*
* @author steve
*/
public class ObjectdbTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("test.odb");
        PersistenceManager pm = pmf.getPersistenceManager();
        // Clear out existing objects
        pm.currentTransaction().begin();
        Query query = pm.newQuery(Example.class);
        query.deletePersistentAll();
        pm.currentTransaction().commit();
        pm.currentTransaction().begin();
        Example example1 = new Example();
        example1.setId(1);
        example1.setName("name1");
        example1.setData(new byte[1]);
        example1.getData()[0] = 123;
        Example example2 = new Example();
        example2.setId(2);
        example2.setName("name2");
        example2.setData(new byte[2]);
        example2.getData()[0] = 12;
        pm.makePersistent(example1);
        pm.makePersistent(example2);
        pm.currentTransaction().commit();
        query = pm.newQuery(Example.class, "name == :name");
        List<Example> dataList = (List<Example>) query.execute("name1");
        for (Example data : dataList) {
            System.out.print(data);
        }
    }
   
}
package spiffy.test.model;

/**
*
* @author steve
*/
public class Example {

    private long id;
    private String name;
    private byte[] data;

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the data
     */
    public byte[] getData() {
        return data;
    }

    /**
     * @param data the data to set
     */
    public void setData(byte[] data) {
        this.data = data;
    }
}
<?xml version="1.0"?>
<jdo xmlns="http://xmlns.jcp.org/xml/ns/jdo/jdo"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/jdo/jdo
        http://xmlns.jcp.org/xml/ns/jdo/jdo_2_0.xsd" version="2.0">
    <package name="spiffy.test.model">
        <class name="Example">
            <field name="id" primary-key="true"/>
            <field name="name" persistence-modifier="persistent"/>
            <field name="data" persistence-modifier="persistent"/>
        </class>
   </package>
</jdo>
Exception in thread "main" [ObjectDB 2.7.1_01] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) 64-Bit Server VM 1.8.0_131 (on Linux 4.10.0-33-generic).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: null
com.objectdb.o.InternalException
at com.objectdb.o.InternalException.f(InternalException.java:236)
at com.objectdb.o.STA.K(STA.java:348)
at com.objectdb.o.ENT.F(ENT.java:546)
at com.objectdb.o.LDR.M(LDR.java:855)
at com.objectdb.o.LDR.L(LDR.java:834)
at com.objectdb.o.LDR.Vz(LDR.java:1061)
at com.objectdb.o.RTT.G(RTT.java:267)
at com.objectdb.o.RTT.F(RTT.java:249)
at com.objectdb.o.RST.C(RST.java:180)
at com.objectdb.o.RTT.l(RTT.java:134)
at com.objectdb.o.RST.l(RST.java:24)
at com.objectdb.o.TSK.i(TSK.java:145)
at com.objectdb.o.TSK.f(TSK.java:95)
at com.objectdb.o.MST.a1(MST.java:609)
at com.objectdb.o.MST.U7(MST.java:565)
at com.objectdb.o.WRA.U7(WRA.java:279)
at com.objectdb.o.LDR.G(LDR.java:583)
at com.objectdb.o.LDR.F(LDR.java:473)
at com.objectdb.o.OBC.U2(OBC.java:1102)
at com.objectdb.o.QRR.f(QRR.java:222)
at com.objectdb.jdo.JdoQuery.execute0(JdoQuery.java:844)
at com.objectdb.jdo.JdoQuery.execute(JdoQuery.java:761)
at spiffy.test.ObjectdbTest.main(ObjectdbTest.java:42)
#2

There was a bug in handling JDO delete queries. Please try build 2.7.1_07.

ObjectDB Support

Reply