openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Hartner <ahart...@Thunderhead.com>
Subject StackOverflow with simple entity
Date Tue, 01 Jul 2008 09:37:15 GMT
I am trying to persist a series of very simple entities using OpenJPA 1.1. I am able to persist
up to 500 instances in sequence, however trying to add more then 600 entities using the example
below fails with a StackOverflowError as shown in the stacktrace below. I have tested with
with version 1.0, 1.0.1, 1.0.2, 1.1.0 as well as 1.1.0-SnapShot and it fails in all cases.

Below are the stacktace, the entity and the test case. The stack trace repeat a couple of
more times which is not shows here.

First Transaction Boundary
Interim Transaction Boundary : 250
Interim Transaction Boundary : 500
Exception in thread "main" java.lang.StackOverflowError
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.openjpa.enhance.Reflection.getDeclaredField(Reflection.java:201)
        at org.apache.openjpa.enhance.Reflection.findField(Reflection.java:180)
        at org.apache.openjpa.enhance.com$jpa$playground$entities$Blobby$pcsubclass.pcProvideField(Unknown
Source)
        at org.apache.openjpa.kernel.StateManagerImpl.provideField(StateManagerImpl.java:3003)
        at org.apache.openjpa.kernel.SaveFieldManager.isFieldEqual(SaveFieldManager.java:189)
        at org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:824)
        at org.apache.openjpa.kernel.ManagedCache.dirtyCheck(ManagedCache.java:307)
        at org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3786)
        at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3903)
        at org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:220)
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1571)
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1511)
        at org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:825)
        at org.apache.openjpa.kernel.ManagedCache.dirtyCheck(ManagedCache.java:307)
        at org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3786)
        at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3903)
        at org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:220)
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1571)
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1511)
        at org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:825)
        at org.apache.openjpa.kernel.ManagedCache.dirtyCheck(ManagedCache.java:307)
        at org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3786)
        at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3903)
        at org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:220)
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1571)
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1511)
        at org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.java:825)
        at org.apache.openjpa.kernel.ManagedCache.dirtyCheck(ManagedCache.java:307)
        at org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.java:3786)
        at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3903)


  public static void main(String[] args) {
        byte[] data = DataGenerator.generateData(5000);
        long step0 = System.currentTimeMillis();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("entityManagerOpenJPA");
        EntityManager em = emf.createEntityManager();
        long step1 = System.currentTimeMillis();
        System.out.println("First Transaction Boundary");
        em.getTransaction().begin();
        int index = 0;
        double commitCount = 0;
        int maximum = 800;
        for (index = 0; index < maximum; index++) {
            Blobby blobby = new Blobby();
            blobby.setSortOrder(index);
            blobby.setData(data);
            em.persist(blobby);
            if (index % 250 == 0 && index > 0 && index < maximum) {
                em.getTransaction().commit();
                System.out.println("Interim Transaction Boundary : "+index);
                commitCount++;
                em.getTransaction().begin();
            }
        }
        commitCount++;
        em.getTransaction().commit();
        System.out.println("Final Transaction Boundary : "+index);
        em.close();
        long end = System.currentTimeMillis();
        System.out.println("Completed in  : " + (end - step0) + " : " + (end - step1) + "
Rate : " + ((end - step1) / commitCount)+" ms/Commit. Commits : "+commitCount);
    }

package com.jpa.playground.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "JS_BINENVELOPES")
public class BinEnvelope implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    private int m_id;
    @Column(name = "SORTORDER")
    private int m_sortOrder;
    @Column(name = "BINID", nullable = false)
    private int m_binId;
    @Column(name = "ENVELOPEID", nullable = false)
    private int m_envelopeId;

    public int getId() {
        return m_id;
    }

    public void setId(int id) {
        m_id = id;
    }

    public int getSortOrder() {
        return m_sortOrder;
    }

    public void setSortOrder(int sortOrder) {
        this.m_sortOrder = sortOrder;
    }

    public int getBinId() {
        return m_binId;
    }

    public void setBinId(int binId) {
        this.m_binId = binId;
    }

    public int getEnvelopeId() {
        return m_envelopeId;
    }

    public void setEnvelopeId(int envelopeId) {
        this.m_envelopeId = envelopeId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += m_id;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof BinEnvelope)) {
            return false;
        }
        BinEnvelope other = (BinEnvelope) object;
        return m_id==other.m_id;
    }

    @Override
    public String toString() {
        return " com.jpa.playground.entities.BinEnvelope[id=" + m_id + "]";
    }
}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message