openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From catalina wei <catalina....@gmail.com>
Subject Re: StackOverflowError thrown on a selection with 2 subselects
Date Fri, 03 Sep 2010 17:01:17 GMT
Hi Savouillan,
This is likely a bug.
Which version of OpenJPA SNAPSHOT are you using ?
Could you provide entity source code for reproducing the problem ?
Thanks.

Catalina

On Tue, Aug 31, 2010 at 7:12 AM, Savouillan Lionel <lsavouillan@axway.com>wrote:

> Hello,
>
>
>
> I encounter a StackOverflowError while running a simple selection. I'll
> try to explain as clearly as possible the context where the bug occurs:
>
>
>
> Here are my objects:
>
> A is persisted entity.
>
> A has a name field.
>
> A contains a tree structure of B.
>
> B is a persisted entity.
>
> B may have a B parent and may have B children.
>
> B has a name field.
>
> B has a path field which is build by collapsing all the parent names.
>
>
>
>
>
> Here is an example (syntax used: instanceName = className{attributeName:
> attributeValue, attributeName: attributeValue, ...};) :
>
> A = A{name: "A"};
>
> rootB = B{parentA: A, name: rootB};
>
> B1 = {parentA: A, name: "B1", parentB: rootB, path: "B1"};
>
> B11 = {parentA: A, name: "B11", parentB: B1, path: "B1.B11"};
>
> B12 = {parentA: A, name: "B12", parentB: B1, path: "B1.B12"};
>
> B111 = {parentA: A, name: "B11", parentB: B11, path: "B1.B11.B111"};
>
>
>
>
>
> Here is the query that I run:
>
> SELECT DISTINCT b from B b1, B b2 WHERE (LOCATE(b2.path, b1.path) = 1 OR
> b1.path = b2.path) AND (b2.name LIKE :arg1) AND (b1.parentA IN (SELECT
> DISTINCT a from A a WHERE a.name LIKE :arg2)) AND (b2.parentA IN (SELECT
> DISTINCT a from A a WHERE a.name LIKE :arg2))
>
>
>
>
>
> Here is the stacktrace:
>
> java.lang.StackOverflowError
>                at
> org.apache.openjpa.jdbc.sql.SelectImpl.aliasSize(SelectImpl.java:2132)
>                at
> org.apache.openjpa.jdbc.sql.SelectImpl.aliasSize(SelectImpl.java:2140)
>                at
> org.apache.openjpa.jdbc.sql.SelectImpl.aliasSize(SelectImpl.java:2132)
>                at
> org.apache.openjpa.jdbc.sql.SelectImpl.aliasSize(SelectImpl.java:2140)
>                at
> org.apache.openjpa.jdbc.sql.SelectImpl.aliasSize(SelectImpl.java:2132)
>                at
> org.apache.openjpa.jdbc.sql.SelectImpl.aliasSize(SelectImpl.java:2140)
>
>                at ...
>
>
>
> Here is the method into the JPA sources where the loop occurs:
>
> 2128:    /**
>
> 2129:     * Calculate total number of aliases.
>
> 2130:     */
>
> 2131:    private int aliasSize(SelectImpl fromSub) {
>
> 2132:        int aliases = (_parent == null) ? 0
>
> 2133:            : _parent.aliasSize(this);
>
> 2134:        aliases += (_aliases == null) ? 0 : _aliases.size();
>
> 2135:        if (_subsels != null) {
>
> 2136:            SelectImpl sub;
>
> 2137:            for (int i = 0; i < _subsels.size(); i++) {
>
> 2138:                sub = (SelectImpl) _subsels.get(i);
>
> 2139:                if (sub != fromSub)
>
> 2140:                    aliases += sub.aliasSize(null);
>
> 2141:            }
>
> 2142:        }
>
> 2143:        return aliases;
>
> 2144:    }
>
>
>
>
>
> The problem seems to occur when multiple subqueries are present.
>
> If I remove the second IN clause, the problem does not occur.
>
> I also suspect the problem occurs when multiple subqueries select the
> same object. I may be wrong, though.
>
>
>
> Any help is welcomed.
>
> Thanks.
>
>
>
> --
>
> Lionel Savouillan
>
>

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