mirror of
https://github.com/apache/openjpa.git
synced 2025-02-21 01:15:30 +00:00
OPENJPA-2039: Update configuration properties.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1158027 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
27a7e91688
commit
e032624813
@ -294,4 +294,21 @@ public class DelegatingJDBCFetchConfiguration
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setIgnoreDfgForFkSelect(boolean b) {
|
||||
try {
|
||||
getJDBCDelegate().setIgnoreDfgForFkSelect(b);
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIgnoreDfgForFkSelect() {
|
||||
try {
|
||||
return getJDBCDelegate().getIgnoreDfgForFkSelect();
|
||||
} catch (RuntimeException re) {
|
||||
throw translate(re);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,4 +241,20 @@ public interface JDBCFetchConfiguration
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public JDBCFetchConfiguration addFetchInnerJoins(Collection<String> fields);
|
||||
|
||||
/**
|
||||
* If true - Ignore whether or not a field is in the dfg for mappings that use 2-part selects to load fk table data.
|
||||
*
|
||||
* @since 2.2.0
|
||||
* @return false
|
||||
*/
|
||||
public boolean getIgnoreDfgForFkSelect();
|
||||
|
||||
/**
|
||||
* If true - Ignore whether or not a field is in the dfg for mappings that use 2-part selects to load fk table data.
|
||||
*
|
||||
* @since 2.2.0
|
||||
* @return false
|
||||
*/
|
||||
public void setIgnoreDfgForFkSelect(boolean b);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public class JDBCFetchConfigurationImpl
|
||||
public Set<String> joins = null;
|
||||
public Set<String> fetchInnerJoins = null;
|
||||
public int isolationLevel = -1;
|
||||
public boolean ignoreDfgForFkSelect = false;
|
||||
}
|
||||
|
||||
protected final JDBCConfigurationState _state;
|
||||
@ -135,8 +136,17 @@ public class JDBCFetchConfigurationImpl
|
||||
setLRSSize(jf.getLRSSize());
|
||||
setJoinSyntax(jf.getJoinSyntax());
|
||||
addJoins(jf.getJoins());
|
||||
setIgnoreDfgForFkSelect(jf.getIgnoreDfgForFkSelect());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIgnoreDfgForFkSelect() {
|
||||
return _state.ignoreDfgForFkSelect;
|
||||
}
|
||||
@Override
|
||||
public void setIgnoreDfgForFkSelect(boolean b) {
|
||||
_state.ignoreDfgForFkSelect = b;
|
||||
}
|
||||
public int getEagerFetchMode() {
|
||||
return _state.eagerMode;
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ public class JDBCStoreManager implements StoreManager, JDBCStore {
|
||||
private RefCountConnection _conn = null;
|
||||
private boolean _active = false;
|
||||
private Log _log = null;
|
||||
boolean _ignoreDfgForFkSelect = false;
|
||||
|
||||
// track the pending statements so we can cancel them
|
||||
private Set<Statement> _stmnts = Collections.synchronizedSet(new HashSet<Statement>());
|
||||
@ -1410,7 +1409,7 @@ public class JDBCStoreManager implements StoreManager, JDBCStore {
|
||||
*/
|
||||
private boolean optSelect(FieldMapping fm, Select sel, OpenJPAStateManager sm, JDBCFetchConfiguration fetch) {
|
||||
boolean dfg =
|
||||
_ignoreDfgForFkSelect ||
|
||||
fetch.getIgnoreDfgForFkSelect() ||
|
||||
!fm.isInDefaultFetchGroup() && !fm.isDefaultFetchGroupExplicit();
|
||||
|
||||
return dfg && (sm == null || sm.getPCState() == PCState.TRANSIENT || !sm.getLoaded().get(fm.getIndex()))
|
||||
@ -1551,10 +1550,6 @@ public class JDBCStoreManager implements StoreManager, JDBCStore {
|
||||
? getConfiguration().getFinderCacheInstance() : null;
|
||||
}
|
||||
|
||||
public void setIgnoreDfgForFkSelect(boolean b) {
|
||||
_ignoreDfgForFkSelect = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection returned to client code. Makes sure its wrapped connection ref count is decremented on finalize.
|
||||
*/
|
||||
|
@ -227,4 +227,20 @@ public interface JDBCFetchPlan
|
||||
* @deprecated use {@link #setJoinSyntax(JoinSyntax)} instead.
|
||||
*/
|
||||
public JDBCFetchPlan setJoinSyntax(int syntax);
|
||||
|
||||
/**
|
||||
* If true - Ignore whether or not a field is in the dfg for mappings that use 2-part selects to load fk table data.
|
||||
*
|
||||
* @since 2.2.0
|
||||
* @return false
|
||||
*/
|
||||
public boolean getIgnoreDfgForFkSelect();
|
||||
|
||||
/**
|
||||
* If true - Ignore whether or not a field is in the dfg for mappings that use 2-part selects to load fk table data.
|
||||
*
|
||||
* @since 2.2.0
|
||||
* @return false
|
||||
*/
|
||||
public void setIgnoreDfgForFkSelect(boolean b);
|
||||
}
|
||||
|
@ -20,8 +20,6 @@ package org.apache.openjpa.persistence.jdbc;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.LockModeType;
|
||||
|
||||
@ -343,4 +341,14 @@ public class JDBCFetchPlanImpl
|
||||
public JDBCFetchPlan setQueryTimeout(int timeout) {
|
||||
return (JDBCFetchPlan) super.setQueryTimeout(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIgnoreDfgForFkSelect() {
|
||||
return _fetch.getIgnoreDfgForFkSelect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreDfgForFkSelect(boolean b) {
|
||||
_fetch.setIgnoreDfgForFkSelect(b);
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,12 @@ import org.apache.openjpa.meta.MetaDataRepository;
|
||||
import org.apache.openjpa.persistence.EntityManagerImpl;
|
||||
import org.apache.openjpa.persistence.FetchPlan;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
||||
import org.apache.openjpa.persistence.jdbc.JDBCFetchPlan;
|
||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||
|
||||
public class TestJDBCStoreOptSelect extends SQLListenerTestCase {
|
||||
Object[] props = new Object[] { CLEAR_TABLES, OptSelectEntity.class };
|
||||
Object[] props = new Object[] { CLEAR_TABLES, OptSelectEntity.class
|
||||
};
|
||||
OptSelectEntity e1, e2;
|
||||
|
||||
@Override
|
||||
@ -50,10 +52,11 @@ public class TestJDBCStoreOptSelect extends SQLListenerTestCase {
|
||||
if (store instanceof JDBCStoreManager == false) {
|
||||
fail("StoreManager is not an instanceof JDBCStoreManager");
|
||||
}
|
||||
// Set this JDBCStoreManager property so that we will select FKs for fields that are in the DFG, but not
|
||||
// included in the current select.
|
||||
((JDBCStoreManager) store).setIgnoreDfgForFkSelect(true);
|
||||
|
||||
// Set this JDBCFetchPlan property so that we will select FKs for fields that are in the DFG, but not
|
||||
// included in the current load. If this property isn't set, the FK for eagerOneToOneOwner will not be
|
||||
// selected.
|
||||
((JDBCFetchPlan)fp).setIgnoreDfgForFkSelect(true);
|
||||
|
||||
// Remove all relationships
|
||||
fp.removeField(OptSelectEntity.class, "eagerOneToOne");
|
||||
fp.removeField(OptSelectEntity.class, "eagerOneToOneOwner");
|
||||
@ -77,6 +80,7 @@ public class TestJDBCStoreOptSelect extends SQLListenerTestCase {
|
||||
fks++;
|
||||
}
|
||||
}
|
||||
// We expected to find 2 FKs. One for each of the owners (lazyOneToOneOwner and eagerOneToOneOwner)
|
||||
assertEquals(2, fks);
|
||||
} finally {
|
||||
if (em.getTransaction().isActive()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user