OutOfMemoryError
ecka Sep 5, 2003 3:06 AMI have a bidirectional CMR relation (a tree with folders and objects). One of the folders contains 1 million objects (inserted directly to the DB). But when I'm using the EJB I get OutOfMemoryError.
2003-09-05 10:15:45,984 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
javax.ejb.EJBException: Unexpected Error
java.lang.OutOfMemoryError
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:182)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:483)
at org.jboss.ejb.Container.invoke(Container.java:674)
at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
at $Proxy125.addChild(Unknown Source)
at se.teligent.tsp.tree.ejb.TreeFacadeBean.addChildToNode(TreeFacadeBean.java:66)
The last log before the stacktrace is from JDBCLoadRelationCommand "Executing SQL:".
I checked exactly what the SQL was and it would find 1000104 rows. And the object I was trying to insert was not even in the folder that contained the 1 million other objects (but .
The SQL log was
1. INSERT INTO tree (id, parent) VALUES (10001001103, null)
2. SELECT parent, id FROM tree WHERE (parent=10000000002) OR (parent=10000000003) OR (parent=10000000004) OR (parent=10000000005) OR (parent=10000000006) OR (parent=10000000007)
And the database looks like
+-------------+-------------+
| id | parent |
+-------------+-------------+
| 10000000001 | NULL |
| 10000000002 | 10000000001 |
| 10000000003 | 10000000001 |
| 10000000004 | 10000000001 |
| 10000000005 | 10000000001 |
| 10000000006 | 10000000001 |
| 10000000007 | 10000000001 |
| 10000000011 | 10000000002 |
| 10000000014 | 10000000007 |
| 10000001000 | 10000000004 |
| 10000001001 | 10000000003 |
| 10000001002 | 10000000003 |
| 10000001003 | 10000000003 |
| 10000001004 | 10000000003 |
| ...
+-------------+-------------+
My question would be:
1. Why does JBoss search for all those objects?
2. If I'm trying to insert a new object to the parent containing the 1 million objects - how can achieve that without searching for all its siblings?