Hello,

I ran your test class and it worked fine.  Since there is no linkage
between the 1000 instances you are creating, I see no reason for a
stack overflow.  I even added some code to link a tabela to its pai
(father, if babel fish is right).  That still does not produce a stack
overflow...

Are you actually getting the stack overflow with the simple test case
you posted?  If so, as Craig asked, can you post the full stacktrace?
Also, could you post your schema?

Christian

On 10/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Sorry,
>
> Here the source code.
> Please help me.
>
>
> Teste.java
> ============================================================================
> import java.util.Iterator;
> import java.util.List;
>
> import javax.persistence.EntityManager;
> import javax.persistence.EntityManagerFactory;
> import javax.persistence.EntityTransaction;
> import javax.persistence.Persistence;
>
> public class Teste {
>
>        /**
>         * @param args
>         */
>        public static void main(String[] args) {
>                EntityManagerFactory emf;
>                emf = Persistence.createEntityManagerFactory("default", System
>                                .getProperties());
>                EntityManager em = (EntityManager) emf.createEntityManager();
>                EntityTransaction transaction = em.getTransaction();
>
>                transaction.begin();
>                for (int x = 0; x < 1000; x++) {
>                        em.persist(new Tabela(x, "Id " + x));
>                }
>                transaction.commit();
>
>
>                transaction.begin();
>                List l = (List<Tabela>) em.createQuery("SELECT a FROM Tabela 
> a")
>                                .getResultList();
>                Iterator i = l.iterator();
>                while (i.hasNext()) {
>                        Tabela tb = (Tabela) i.next();
>                        System.out.println(tb);
>                }
>                transaction.commit();
>
>        }
>
> }
> ============================================================================
>
>
> Tabela.java
> ============================================================================
>
> import java.io.Serializable;
> import java.util.List;
>
> import javax.persistence.CascadeType;
> import javax.persistence.Entity;
> import javax.persistence.Id;
> import javax.persistence.JoinColumn;
> import javax.persistence.ManyToOne;
> import javax.persistence.OneToMany;
>
> import org.apache.openjpa.persistence.InverseLogical;
>
> @Entity
> public class Tabela implements Serializable {
>
>        private static final long serialVersionUID = -7323896668494281866L;
>
>        @Id
>        private int id;
>
>        private String ds;
>
>        @ManyToOne(cascade = CascadeType.REFRESH)
>        @JoinColumn(name = "pai", nullable = true)
>        private Tabela pai;
>
>        @OneToMany(cascade = CascadeType.REFRESH, mappedBy = "pai")
>        @InverseLogical("pai")
>        private List<Tabela> filhos;
>
>        public Tabela(int i, String x) {
>                id = i;
>                ds = x;
>        }
>
>        public String getDs() {
>                return ds;
>        }
>
>        public void setDs(String ds) {
>                this.ds = ds;
>        }
>
>        public int getId() {
>                return id;
>        }
>
>        public void setId(int a) {
>                this.id = a;
>        }
>
>        public Tabela() {
>                super();
>        }
>
>        public String toString() {
>                return "" + id + " " + ds;
>        }
>
>        public List<Tabela> getFilhos() {
>                return filhos;
>        }
>
>        public void setFilhos(List<Tabela> filhos) {
>                this.filhos = filhos;
>        }
>
>        public Tabela getPai() {
>                return pai;
>        }
>
>        public void setPai(Tabela pai) {
>                this.pai = pai;
>        }
>
> }
> ============================================================================
>
>
> tnks
> []s
>
>
> ---------- InĂ­cio da mensagem original -----------
>
>      De: [EMAIL PROTECTED]
>    Para: "users" [email protected]
>      Cc: "dev" [EMAIL PROTECTED]
>    Data: Tue,  2 Oct 2007 20:28:44 -0300
>  Assunto: Exception in thread "main" java.lang.StackOverflowError
>
> > Guys,
> >
> > I do a simple teste and I found that error:
> > Exception in thread "main" java.lang.StackOverflowError
> >       at java.security.AccessController.doPrivileged(Native Method)
> >       at 
> > org.apache.openjpa.enhance.Reflection.getDeclaredField(Reflection.java:166)
> > :
> > :
> >
> > The error occurrs in the last commit "transaction.commit();" at line 36.
> >
> >
> >
> >
>
>

Reply via email to