openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof <yaz...@gmail.com>
Subject Re: Use of AbstractLRSProxyCollection
Date Mon, 19 Sep 2011 23:08:51 GMT
Hello,
I have quite similar problem and I have been inclined to create a custom
LRSCollectionProxy. 

Have you managed to attach yours along with LRS annotation by any chance?

Is it possible to do this or one must create a custom ProxyManager? Or
there's other way? 

There are three implementations of LRSCollectionFieldStrategy that use
LRSCollectionProxy and its not clear how to expand on them for oneToMany
associations with custom LRSCollectionProxy.

As a side note, in the current codebase LRSCollecionProxy always generates
jdbc queries for size() calls, i.e. via PersistAll():
isEmpty()->size()->count() calls chain regardless of the LRSSize setting. 
Also, adding entities to LRS collection always generates SQL that fetches
all entities on persistAll which defies the purpose of the LRS to some
extent.

Check count() in LRSProxyCollection that will always generate the select
count(*) from colTable (unless I'm missing sth..):

 protected int count() {
        final ClassMapping[] elems = _strat.getIndependentElementMappings
            (false);
        final OpenJPAStateManager sm = assertOwner();
        final JDBCStore store = getStore();
        Union union = store.getSQLFactory().newUnion
            (Math.max(1, elems.length));
        union.select(new Union.Selector() {
            public void select(Select sel, int idx) {
                ClassMapping elem = (elems.length == 0) ? null : elems[idx];
                sel.whereForeignKey(_strat.getJoinForeignKey(elem),
                    sm.getObjectId(), _strat.getFieldMapping().
                    getDefiningMapping(), store);
            }
        });

        try {
            return union.getCount(store);
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, store.getDBDictionary());
        }
    }

Should this be treated as a bug, shouldn't it?

Best regards,
Krzysztof



--
View this message in context: http://openjpa.208410.n2.nabble.com/Use-of-AbstractLRSProxyCollection-tp6646826p6810317.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Mime
View raw message