mirror of https://github.com/apache/openjpa.git
changed some more finally and catch blocks that didn't get properly reformatted with earlier reformattings / sed scripts
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@423693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b108a39e7e
commit
a1f4fd3eb0
|
@ -63,8 +63,8 @@ public abstract class AbstractUpdateManager
|
|||
public Collection flush(Collection states, JDBCStore store) {
|
||||
Connection conn = store.getConnection();
|
||||
try {
|
||||
PreparedStatementManager psMgr = newPreparedStatementManager
|
||||
(store, conn);
|
||||
PreparedStatementManager psMgr = newPreparedStatementManager(store,
|
||||
conn);
|
||||
return flush(states, store, psMgr);
|
||||
} finally {
|
||||
try {
|
||||
|
@ -81,9 +81,8 @@ public abstract class AbstractUpdateManager
|
|||
Collection customs = new LinkedList();
|
||||
Collection exceps = null;
|
||||
for (Iterator itr = states.iterator(); itr.hasNext();)
|
||||
exceps =
|
||||
populateRowManager((OpenJPAStateManager) itr.next(), rowMgr,
|
||||
store, exceps, customs);
|
||||
exceps = populateRowManager((OpenJPAStateManager) itr.next(),
|
||||
rowMgr, store, exceps, customs);
|
||||
|
||||
// flush rows
|
||||
exceps = flush(rowMgr, psMgr, exceps);
|
||||
|
@ -93,8 +92,7 @@ public abstract class AbstractUpdateManager
|
|||
try {
|
||||
((CustomMapping) itr.next()).execute(store);
|
||||
} catch (SQLException se) {
|
||||
exceps = addException(exceps, SQLExceptions.getStore(se,
|
||||
dict));
|
||||
exceps = addException(exceps, SQLExceptions.getStore(se, dict));
|
||||
} catch (OpenJPAException ke) {
|
||||
exceps = addException(exceps, ke);
|
||||
}
|
||||
|
@ -118,8 +116,8 @@ public abstract class AbstractUpdateManager
|
|||
/**
|
||||
* Return a new {@link PreparedStatementManager}.
|
||||
*/
|
||||
protected abstract PreparedStatementManager newPreparedStatementManager
|
||||
(JDBCStore store, Connection conn);
|
||||
protected abstract PreparedStatementManager newPreparedStatementManager(
|
||||
JDBCStore store, Connection conn);
|
||||
|
||||
/**
|
||||
* Flush all rows of the given row manager. Add exceptions to
|
||||
|
@ -142,16 +140,15 @@ public abstract class AbstractUpdateManager
|
|||
Collection customs) {
|
||||
try {
|
||||
if (sm.getPCState() == PCState.PNEW && !sm.isFlushed()) {
|
||||
insert(sm, (ClassMapping) sm.getMetaData(), rowMgr,
|
||||
store, customs);
|
||||
insert(sm, (ClassMapping) sm.getMetaData(), rowMgr, store,
|
||||
customs);
|
||||
} else if (sm.getPCState() == PCState.PNEWFLUSHEDDELETED
|
||||
|| sm.getPCState() == PCState.PDELETED) {
|
||||
delete(sm, (ClassMapping) sm.getMetaData(), rowMgr,
|
||||
store, customs);
|
||||
} else if ((sm.getPCState() == PCState.PDIRTY
|
||||
&& (!sm.isFlushed() || sm.isFlushedDirty()))
|
||||
|| (sm.getPCState() == PCState.PNEW
|
||||
&& sm.isFlushedDirty())) {
|
||||
delete(sm, (ClassMapping) sm.getMetaData(), rowMgr, store,
|
||||
customs);
|
||||
} else if ((sm.getPCState() == PCState.PDIRTY && (!sm.isFlushed() || sm
|
||||
.isFlushedDirty()))
|
||||
|| (sm.getPCState() == PCState.PNEW && sm.isFlushedDirty())) {
|
||||
BitSet dirty = sm.getDirty();
|
||||
if (sm.isFlushed()) {
|
||||
dirty = (BitSet) dirty.clone();
|
||||
|
@ -159,19 +156,18 @@ public abstract class AbstractUpdateManager
|
|||
}
|
||||
|
||||
if (dirty.length() > 0)
|
||||
update(sm, dirty, (ClassMapping) sm.getMetaData(),
|
||||
rowMgr, store, customs);
|
||||
update(sm, dirty, (ClassMapping) sm.getMetaData(), rowMgr,
|
||||
store, customs);
|
||||
} else if (sm.isVersionUpdateRequired()) {
|
||||
updateIndicators(sm, (ClassMapping) sm.getMetaData(),
|
||||
rowMgr, store, customs, true);
|
||||
updateIndicators(sm, (ClassMapping) sm.getMetaData(), rowMgr,
|
||||
store, customs, true);
|
||||
} else if (sm.isVersionCheckRequired()) {
|
||||
if (!((ClassMapping) sm.getMetaData()).getVersion().
|
||||
checkVersion(sm, store, false))
|
||||
exceps = addException(exceps, new OptimisticException
|
||||
(sm.getManagedInstance()));
|
||||
if (!((ClassMapping) sm.getMetaData()).getVersion()
|
||||
.checkVersion(sm, store, false))
|
||||
exceps = addException(exceps, new OptimisticException(sm
|
||||
.getManagedInstance()));
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
} catch (SQLException se) {
|
||||
exceps = addException(exceps, SQLExceptions.getStore(se, dict));
|
||||
} catch (OpenJPAException ke) {
|
||||
exceps = addException(exceps, ke);
|
||||
|
@ -284,8 +280,7 @@ public abstract class AbstractUpdateManager
|
|||
*/
|
||||
private void update(OpenJPAStateManager sm, BitSet dirty,
|
||||
ClassMapping mapping, RowManager rowMgr, JDBCStore store,
|
||||
Collection customs)
|
||||
throws SQLException {
|
||||
Collection customs) throws SQLException {
|
||||
Boolean custom = mapping.isCustomUpdate(sm, store);
|
||||
if (!Boolean.FALSE.equals(custom))
|
||||
mapping.customUpdate(sm, store);
|
||||
|
@ -314,8 +309,7 @@ public abstract class AbstractUpdateManager
|
|||
*/
|
||||
private void updateIndicators(OpenJPAStateManager sm, ClassMapping mapping,
|
||||
RowManager rowMgr, JDBCStore store, Collection customs,
|
||||
boolean versionUpdateOnly)
|
||||
throws SQLException {
|
||||
boolean versionUpdateOnly) throws SQLException {
|
||||
while (mapping.getJoinablePCSuperclassMapping() != null)
|
||||
mapping = mapping.getJoinablePCSuperclassMapping();
|
||||
|
||||
|
@ -359,25 +353,23 @@ public abstract class AbstractUpdateManager
|
|||
private final OpenJPAStateManager _sm;
|
||||
private final Strategy _strat;
|
||||
|
||||
public CustomMapping(int action, OpenJPAStateManager sm,
|
||||
Strategy strat) {
|
||||
public CustomMapping(int action, OpenJPAStateManager sm, Strategy strat) {
|
||||
_action = action;
|
||||
_sm = sm;
|
||||
_strat = strat;
|
||||
}
|
||||
|
||||
public void execute(JDBCStore store)
|
||||
throws SQLException {
|
||||
public void execute(JDBCStore store) throws SQLException {
|
||||
switch (_action) {
|
||||
case INSERT:
|
||||
_strat.customInsert(_sm, store);
|
||||
break;
|
||||
case UPDATE:
|
||||
_strat.customUpdate(_sm, store);
|
||||
break;
|
||||
case DELETE:
|
||||
_strat.customDelete(_sm, store);
|
||||
break;
|
||||
case INSERT:
|
||||
_strat.customInsert(_sm, store);
|
||||
break;
|
||||
case UPDATE:
|
||||
_strat.customUpdate(_sm, store);
|
||||
break;
|
||||
case DELETE:
|
||||
_strat.customDelete(_sm, store);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@ import org.apache.openjpa.meta.JavaTypes;
|
|||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
public class ClassTableJDBCSeq
|
||||
public class ClassTableJDBCSeq
|
||||
extends TableJDBCSeq {
|
||||
|
||||
private static final Localizer _loc = Localizer.forPackage
|
||||
(ClassTableJDBCSeq.class);
|
||||
private static final Localizer _loc = Localizer
|
||||
.forPackage(ClassTableJDBCSeq.class);
|
||||
|
||||
private final Map _stats = new HashMap();
|
||||
private boolean _ignore = false;
|
||||
|
@ -109,8 +109,8 @@ public class ClassTableJDBCSeq
|
|||
|
||||
protected Column addPrimaryKeyColumn(Table table) {
|
||||
DBDictionary dict = getConfiguration().getDBDictionaryInstance();
|
||||
Column pkColumn = table.addColumn(dict.getValidColumnName
|
||||
(getPrimaryKeyColumn(), table));
|
||||
Column pkColumn = table.addColumn(dict.getValidColumnName(
|
||||
getPrimaryKeyColumn(), table));
|
||||
pkColumn.setType(dict.getPreferredType(Types.VARCHAR));
|
||||
pkColumn.setJavaType(JavaTypes.STRING);
|
||||
pkColumn.setSize(dict.characterColumnSize);
|
||||
|
@ -163,8 +163,7 @@ public class ClassTableJDBCSeq
|
|||
* <li><i>set</i>: Set the sequence value for the given class.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Options opts = new Options();
|
||||
args = opts.setFromCmdLine(args);
|
||||
JDBCConfiguration conf = new JDBCConfigurationImpl();
|
||||
|
@ -180,8 +179,7 @@ public class ClassTableJDBCSeq
|
|||
* Run the tool. Returns false if invalid options were given.
|
||||
*/
|
||||
public static boolean run(JDBCConfiguration conf, String[] args,
|
||||
Options opts)
|
||||
throws Exception {
|
||||
Options opts) throws Exception {
|
||||
if (opts.containsKey("help") || opts.containsKey("-help"))
|
||||
return false;
|
||||
|
||||
|
@ -213,11 +211,11 @@ public class ClassTableJDBCSeq
|
|||
return false;
|
||||
|
||||
if (loader == null)
|
||||
loader = conf.getClassResolverInstance().
|
||||
getClassLoader(ClassTableJDBCSeq.class, null);
|
||||
loader = conf.getClassResolverInstance().getClassLoader(
|
||||
ClassTableJDBCSeq.class, null);
|
||||
|
||||
ClassArgParser cap = conf.getMetaDataRepository().
|
||||
getMetaDataFactory().newClassArgParser();
|
||||
ClassArgParser cap = conf.getMetaDataRepository()
|
||||
.getMetaDataFactory().newClassArgParser();
|
||||
cap.setClassLoader(loader);
|
||||
Class cls = cap.parseTypes(args[0])[0];
|
||||
|
||||
|
@ -246,8 +244,7 @@ public class ClassTableJDBCSeq
|
|||
}
|
||||
System.err.println(mapping + ": " + set);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
} catch (NumberFormatException nfe) {
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
|
|
|
@ -81,11 +81,11 @@ import org.apache.openjpa.util.UserException;
|
|||
* @author Abe White
|
||||
* @nojavadoc
|
||||
*/
|
||||
public class JDBCStoreManager
|
||||
public class JDBCStoreManager
|
||||
implements StoreManager, JDBCStore {
|
||||
|
||||
private static final Localizer _loc = Localizer.forPackage
|
||||
(JDBCStoreManager.class);
|
||||
private static final Localizer _loc = Localizer
|
||||
.forPackage(JDBCStoreManager.class);
|
||||
|
||||
private StoreContext _ctx = null;
|
||||
private JDBCConfiguration _conf = null;
|
||||
|
@ -142,10 +142,10 @@ public class JDBCStoreManager
|
|||
return (JDBCFetchConfiguration) _ctx.getFetchConfiguration();
|
||||
}
|
||||
|
||||
private JDBCFetchConfiguration getFetchConfiguration
|
||||
(JDBCFetchState fetchState) {
|
||||
return (fetchState == null) ? getFetchConfiguration()
|
||||
: fetchState.getJDBCFetchConfiguration();
|
||||
private JDBCFetchConfiguration getFetchConfiguration(
|
||||
JDBCFetchState fetchState) {
|
||||
return (fetchState == null) ? getFetchConfiguration() : fetchState
|
||||
.getJDBCFetchConfiguration();
|
||||
}
|
||||
|
||||
public void beginOptimistic() {
|
||||
|
@ -187,8 +187,9 @@ public class JDBCStoreManager
|
|||
return;
|
||||
|
||||
try {
|
||||
if (_conn != null && (!_ctx.isManaged()
|
||||
|| !_conf.isConnectionFactoryModeManaged()))
|
||||
if (_conn != null
|
||||
&& (!_ctx.isManaged() || !_conf
|
||||
.isConnectionFactoryModeManaged()))
|
||||
_conn.rollback();
|
||||
} catch (SQLException se) {
|
||||
throw SQLExceptions.getStore(se, _dict);
|
||||
|
@ -256,8 +257,7 @@ public class JDBCStoreManager
|
|||
FetchState fetchState, Object context) {
|
||||
ConnectionInfo info = (ConnectionInfo) context;
|
||||
try {
|
||||
return initializeState(sm, state, (JDBCFetchState) fetchState,
|
||||
info);
|
||||
return initializeState(sm, state, (JDBCFetchState) fetchState, info);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
throw new UserException(cnfe);
|
||||
} catch (SQLException se) {
|
||||
|
@ -281,8 +281,8 @@ public class JDBCStoreManager
|
|||
if (info.mapping == null)
|
||||
info.mapping = mapping;
|
||||
mapping = info.mapping;
|
||||
} else
|
||||
if (oid instanceof OpenJPAId && !((OpenJPAId) oid).hasSubclasses()) {
|
||||
} else if (oid instanceof OpenJPAId
|
||||
&& !((OpenJPAId) oid).hasSubclasses()) {
|
||||
Boolean custom = customLoad(sm, mapping, state, jfetch);
|
||||
if (custom != null)
|
||||
return custom.booleanValue();
|
||||
|
@ -293,8 +293,8 @@ public class JDBCStoreManager
|
|||
if (res != null && !res.next())
|
||||
return false;
|
||||
} else {
|
||||
ClassMapping[] mappings = mapping.
|
||||
getIndependentAssignableMappings();
|
||||
ClassMapping[] mappings = mapping
|
||||
.getIndependentAssignableMappings();
|
||||
if (mappings.length == 1) {
|
||||
mapping = mappings[0];
|
||||
Boolean custom = customLoad(sm, mapping, state, jfetch);
|
||||
|
@ -388,8 +388,7 @@ public class JDBCStoreManager
|
|||
*/
|
||||
private Result getInitializeStateUnionResult(final OpenJPAStateManager sm,
|
||||
ClassMapping mapping, final ClassMapping[] mappings,
|
||||
final JDBCFetchState fetchState)
|
||||
throws SQLException {
|
||||
final JDBCFetchState fetchState) throws SQLException {
|
||||
final JDBCStoreManager store = this;
|
||||
JDBCFetchConfiguration jfetch = getFetchConfiguration(fetchState);
|
||||
final int eager = Math.min(jfetch.getEagerFetchMode(),
|
||||
|
@ -400,6 +399,7 @@ public class JDBCStoreManager
|
|||
if (jfetch.getSubclassFetchMode(mapping) != jfetch.EAGER_JOIN)
|
||||
union.abortUnion();
|
||||
union.select(new Union.Selector() {
|
||||
|
||||
public void select(Select sel, int i) {
|
||||
sel.select(mappings[i], Select.SUBS_ANY_JOINABLE, store,
|
||||
fetchState, eager);
|
||||
|
@ -414,8 +414,7 @@ public class JDBCStoreManager
|
|||
* if needed.
|
||||
*/
|
||||
private boolean selectPrimaryKey(OpenJPAStateManager sm,
|
||||
ClassMapping mapping,
|
||||
JDBCFetchConfiguration jfetch)
|
||||
ClassMapping mapping, JDBCFetchConfiguration jfetch)
|
||||
throws SQLException {
|
||||
// select pks from base class record to ensure it exists and lock
|
||||
// it if needed
|
||||
|
@ -442,8 +441,8 @@ public class JDBCStoreManager
|
|||
|
||||
public boolean load(OpenJPAStateManager sm, BitSet fields,
|
||||
FetchState fetchState, int lockLevel, Object context) {
|
||||
JDBCFetchState jfetchState = (fetchState == null)
|
||||
? (JDBCFetchState) getFetchConfiguration().newFetchState()
|
||||
JDBCFetchState jfetchState = (fetchState == null) ? (JDBCFetchState) getFetchConfiguration()
|
||||
.newFetchState()
|
||||
: (JDBCFetchState) fetchState;
|
||||
|
||||
JDBCFetchConfiguration jfetch = getFetchConfiguration(jfetchState);
|
||||
|
@ -586,8 +585,7 @@ public class JDBCStoreManager
|
|||
|
||||
public Object copyDataStoreId(Object oid, ClassMetaData meta) {
|
||||
Id id = (Id) oid;
|
||||
return new Id(meta.getDescribedType(), id.getId(),
|
||||
id.hasSubclasses());
|
||||
return new Id(meta.getDescribedType(), id.getId(), id.hasSubclasses());
|
||||
}
|
||||
|
||||
public Object newDataStoreId(Object val, ClassMetaData meta) {
|
||||
|
@ -605,12 +603,12 @@ public class JDBCStoreManager
|
|||
if (subclasses)
|
||||
mappings = mapping.getIndependentAssignableMappings();
|
||||
else
|
||||
mappings = new ClassMapping[]{ mapping };
|
||||
mappings = new ClassMapping[] { mapping };
|
||||
|
||||
ResultObjectProvider[] rops = null;
|
||||
final JDBCFetchConfiguration jfetch = (JDBCFetchConfiguration) fetch;
|
||||
final JDBCFetchState jfetchState = (JDBCFetchState)
|
||||
jfetch.newFetchState();
|
||||
final JDBCFetchState jfetchState = (JDBCFetchState) jfetch
|
||||
.newFetchState();
|
||||
if (jfetch.getSubclassFetchMode(mapping) != jfetch.EAGER_JOIN)
|
||||
rops = new ResultObjectProvider[mappings.length];
|
||||
|
||||
|
@ -657,6 +655,7 @@ public class JDBCStoreManager
|
|||
union.setLRS(true);
|
||||
final BitSet[] paged = new BitSet[mappings.length];
|
||||
union.select(new Union.Selector() {
|
||||
|
||||
public void select(Select sel, int idx) {
|
||||
paged[idx] = selectExtent(sel, mappings[idx], jfetchState,
|
||||
subclasses);
|
||||
|
@ -670,8 +669,8 @@ public class JDBCStoreManager
|
|||
JDBCStoreManager.this, jfetchState, paged,
|
||||
Long.MAX_VALUE);
|
||||
}
|
||||
return new InstanceResultObjectProvider(union, mappings[0],
|
||||
this, jfetchState);
|
||||
return new InstanceResultObjectProvider(union, mappings[0], this,
|
||||
jfetchState);
|
||||
} catch (SQLException se) {
|
||||
throw SQLExceptions.getStore(se, _dict);
|
||||
}
|
||||
|
@ -684,8 +683,8 @@ public class JDBCStoreManager
|
|||
JDBCFetchState jfetchState, boolean subclasses) {
|
||||
int subs = (subclasses) ? Select.SUBS_JOINABLE : Select.SUBS_NONE;
|
||||
// decide between paging and standard iteration
|
||||
BitSet paged = PagingResultObjectProvider.getPagedFields(sel,
|
||||
mapping, this, jfetchState, JDBCFetchConfiguration.EAGER_PARALLEL,
|
||||
BitSet paged = PagingResultObjectProvider.getPagedFields(sel, mapping,
|
||||
this, jfetchState, JDBCFetchConfiguration.EAGER_PARALLEL,
|
||||
Long.MAX_VALUE);
|
||||
if (paged == null)
|
||||
sel.selectIdentifier(mapping, subs, this, jfetchState,
|
||||
|
@ -752,16 +751,14 @@ public class JDBCStoreManager
|
|||
* Connect to the database. This method is separated out so that it
|
||||
* can be profiled.
|
||||
*/
|
||||
private RefCountConnection connectInternal()
|
||||
throws SQLException {
|
||||
private RefCountConnection connectInternal() throws SQLException {
|
||||
return new RefCountConnection(_ds.getConnection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the object with the given oid.
|
||||
*/
|
||||
public Object find(Object oid, ValueMapping vm,
|
||||
JDBCFetchState fetchState) {
|
||||
public Object find(Object oid, ValueMapping vm, JDBCFetchState fetchState) {
|
||||
if (oid == null)
|
||||
return null;
|
||||
Object pc = _ctx.find(oid, fetchState, null, null, 0);
|
||||
|
@ -776,11 +773,10 @@ public class JDBCStoreManager
|
|||
* Load the object in the current row of the given result.
|
||||
*/
|
||||
public Object load(ClassMapping mapping, JDBCFetchState fetchState,
|
||||
BitSet exclude, Result result)
|
||||
throws SQLException {
|
||||
BitSet exclude, Result result) throws SQLException {
|
||||
if (!mapping.isMapped())
|
||||
throw new InvalidStateException(_loc.get("virtual-mapping",
|
||||
mapping));
|
||||
throw new InvalidStateException(_loc
|
||||
.get("virtual-mapping", mapping));
|
||||
|
||||
// get the object id for the row; base class selects pk columns
|
||||
ClassMapping base = mapping;
|
||||
|
@ -801,8 +797,7 @@ public class JDBCStoreManager
|
|||
* mappings originally selected will be loaded.
|
||||
*/
|
||||
private void load(ClassMapping mapping, OpenJPAStateManager sm,
|
||||
JDBCFetchState fetchState, Result res)
|
||||
throws SQLException {
|
||||
JDBCFetchState fetchState, Result res) throws SQLException {
|
||||
FieldMapping eagerToMany = load(mapping, sm, fetchState, res, null);
|
||||
if (eagerToMany != null)
|
||||
eagerToMany.loadEagerJoin(sm, this, fetchState, res);
|
||||
|
@ -832,8 +827,7 @@ public class JDBCStoreManager
|
|||
FieldMapping[] fms = mapping.getDefinedFieldMappings();
|
||||
Object eres, processed;
|
||||
for (int i = 0; i < fms.length; i++) {
|
||||
if (fms[i].isPrimaryKey()
|
||||
|| sm.getLoaded().get(fms[i].getIndex()))
|
||||
if (fms[i].isPrimaryKey() || sm.getLoaded().get(fms[i].getIndex()))
|
||||
continue;
|
||||
|
||||
// check for eager result, and if not present do standard load
|
||||
|
@ -894,8 +888,8 @@ public class JDBCStoreManager
|
|||
// preventing infinite recursion
|
||||
JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
|
||||
eager = Math.min(eager, fetch.getEagerFetchMode());
|
||||
FieldMapping eagerToMany = createEagerSelects(sel, mapping, sm,
|
||||
fields, fetchState, eager);
|
||||
FieldMapping eagerToMany = createEagerSelects(sel, mapping, sm, fields,
|
||||
fetchState, eager);
|
||||
|
||||
// select all base class mappings; do this after batching so that
|
||||
// the joins needed by these selects don't get in the WHERE clause
|
||||
|
@ -928,8 +922,8 @@ public class JDBCStoreManager
|
|||
return null;
|
||||
|
||||
JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
|
||||
FieldMapping eagerToMany = createEagerSelects(sel, mapping.
|
||||
getJoinablePCSuperclassMapping(), sm, fields, fetchState, eager);
|
||||
FieldMapping eagerToMany = createEagerSelects(sel, mapping
|
||||
.getJoinablePCSuperclassMapping(), sm, fields, fetchState, eager);
|
||||
|
||||
FieldMapping[] fms = mapping.getDefinedFieldMappings();
|
||||
boolean inEagerJoin = sel.hasEagerJoin(false);
|
||||
|
@ -944,10 +938,9 @@ public class JDBCStoreManager
|
|||
continue;
|
||||
|
||||
// try to select with join first
|
||||
jtype = (fms[i].getNullValue() == fms[i].NULL_EXCEPTION)
|
||||
? sel.EAGER_INNER : sel.EAGER_OUTER;
|
||||
if (mode != fetch.EAGER_PARALLEL
|
||||
&& !fms[i].isEagerSelectToMany()
|
||||
jtype = (fms[i].getNullValue() == fms[i].NULL_EXCEPTION) ? sel.EAGER_INNER
|
||||
: sel.EAGER_OUTER;
|
||||
if (mode != fetch.EAGER_PARALLEL && !fms[i].isEagerSelectToMany()
|
||||
&& fms[i].supportsSelect(sel, jtype, sm, this, fetch) > 0
|
||||
&& sel.eagerClone(fms[i], jtype, false, 1) != null)
|
||||
continue;
|
||||
|
@ -959,13 +952,12 @@ public class JDBCStoreManager
|
|||
// to use a to-many join also. currently we limit eager
|
||||
// outer joins to non-LRS, non-ranged selects that don't already
|
||||
// have an eager to-many join
|
||||
if ((hasJoin || mode == fetch.EAGER_JOIN
|
||||
|| (mode == fetch.DEFAULT && sm != null))
|
||||
if ((hasJoin || mode == fetch.EAGER_JOIN || (mode == fetch.DEFAULT && sm != null))
|
||||
&& fms[i].isEagerSelectToMany()
|
||||
&& !inEagerJoin && !sel.hasEagerJoin(true)
|
||||
&& !inEagerJoin
|
||||
&& !sel.hasEagerJoin(true)
|
||||
&& (!sel.getAutoDistinct() || (!sel.isLRS()
|
||||
&& sel.getStartIndex() == 0
|
||||
&& sel.getEndIndex() == Long.MAX_VALUE))
|
||||
&& sel.getStartIndex() == 0 && sel.getEndIndex() == Long.MAX_VALUE))
|
||||
&& fms[i].supportsSelect(sel, jtype, sm, this, fetch) > 0) {
|
||||
if (sel.eagerClone(fms[i], jtype, true, 1) != null)
|
||||
eagerToMany = fms[i];
|
||||
|
@ -974,10 +966,11 @@ public class JDBCStoreManager
|
|||
}
|
||||
|
||||
// finally, try parallel
|
||||
if (eager == fetch.EAGER_PARALLEL && (sels = fms[i].
|
||||
supportsSelect(sel, sel.EAGER_PARALLEL, sm, this, fetch)) != 0)
|
||||
sel.eagerClone(fms[i], Select.EAGER_PARALLEL,
|
||||
fms[i].isEagerSelectToMany(), sels);
|
||||
if (eager == fetch.EAGER_PARALLEL
|
||||
&& (sels = fms[i].supportsSelect(sel, sel.EAGER_PARALLEL, sm,
|
||||
this, fetch)) != 0)
|
||||
sel.eagerClone(fms[i], Select.EAGER_PARALLEL, fms[i]
|
||||
.isEagerSelectToMany(), sels);
|
||||
}
|
||||
return eagerToMany;
|
||||
}
|
||||
|
@ -986,8 +979,7 @@ public class JDBCStoreManager
|
|||
* Determine if the given field needs to be selected.
|
||||
*/
|
||||
private static boolean requiresSelect(FieldMapping fm,
|
||||
OpenJPAStateManager sm,
|
||||
BitSet fields, JDBCFetchState fetchState) {
|
||||
OpenJPAStateManager sm, BitSet fields, JDBCFetchState fetchState) {
|
||||
if (fields != null)
|
||||
return fields.get(fm.getIndex());
|
||||
if (sm != null && sm.getPCState() != PCState.TRANSIENT
|
||||
|
@ -1018,8 +1010,8 @@ public class JDBCStoreManager
|
|||
JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
|
||||
ClassMapping parent = mapping.getJoinablePCSuperclassMapping();
|
||||
if (parent == null && !mapping.isMapped())
|
||||
throw new InvalidStateException(_loc.get("virtual-mapping",
|
||||
mapping.getDescribedType()));
|
||||
throw new InvalidStateException(_loc.get("virtual-mapping", mapping
|
||||
.getDescribedType()));
|
||||
|
||||
int seld = -1;
|
||||
int pseld = -1;
|
||||
|
@ -1036,9 +1028,9 @@ public class JDBCStoreManager
|
|||
}
|
||||
|
||||
// if no instance or not initialized and not exact oid, select type
|
||||
if ((sm == null || (sm.getPCState() == PCState.TRANSIENT
|
||||
&& (!(sm.getObjectId()instanceof OpenJPAId)
|
||||
|| ((OpenJPAId) sm.getObjectId()).hasSubclasses())))
|
||||
if ((sm == null || (sm.getPCState() == PCState.TRANSIENT && (!(sm
|
||||
.getObjectId() instanceof OpenJPAId) || ((OpenJPAId) sm
|
||||
.getObjectId()).hasSubclasses())))
|
||||
&& mapping.getDiscriminator().select(sel, orig))
|
||||
seld = 1;
|
||||
|
||||
|
@ -1102,13 +1094,12 @@ public class JDBCStoreManager
|
|||
* case as an optimization.
|
||||
*/
|
||||
private boolean optSelect(FieldMapping fm, Select sel,
|
||||
OpenJPAStateManager sm,
|
||||
JDBCFetchState fetchState) {
|
||||
OpenJPAStateManager sm, JDBCFetchState fetchState) {
|
||||
return !fm.isDefaultFetchGroupExplicit()
|
||||
&& (sm == null || sm.getPCState() == PCState.TRANSIENT
|
||||
|| !sm.getLoaded().get(fm.getIndex()))
|
||||
&& (sm == null || sm.getPCState() == PCState.TRANSIENT || !sm
|
||||
.getLoaded().get(fm.getIndex()))
|
||||
&& fm.supportsSelect(sel, sel.TYPE_TWO_PART, sm, this,
|
||||
getFetchConfiguration(fetchState)) > 0
|
||||
getFetchConfiguration(fetchState)) > 0
|
||||
&& fetchState.requiresSelect(fm, true);
|
||||
}
|
||||
|
||||
|
@ -1153,9 +1144,8 @@ public class JDBCStoreManager
|
|||
if (!fms[j].isInDefaultFetchGroup()
|
||||
&& !fetch.hasFetchGroup(fms[j].getFetchGroups())
|
||||
&& !fetch.hasField(fms[j].getFullName())
|
||||
&& (fms[j].isDefaultFetchGroupExplicit()
|
||||
|| fms[j].supportsSelect(sel, sel.TYPE_TWO_PART, sm,
|
||||
this, fetch) <= 0))
|
||||
&& (fms[j].isDefaultFetchGroupExplicit() || fms[j]
|
||||
.supportsSelect(sel, sel.TYPE_TWO_PART, sm, this, fetch) <= 0))
|
||||
continue;
|
||||
|
||||
// if we can join to the subclass, do so; much better chance
|
||||
|
@ -1164,15 +1154,14 @@ public class JDBCStoreManager
|
|||
// mark joined whether or not we join, so we don't have to
|
||||
// test conditions again for this subclass
|
||||
joined = true;
|
||||
sel.where(joinSubclass(sel, mapping, subMappings[i],
|
||||
null));
|
||||
sel.where(joinSubclass(sel, mapping, subMappings[i], null));
|
||||
}
|
||||
|
||||
// if can select with tables already selected, do it
|
||||
if (fms[j].supportsSelect(sel, sel.TYPE_JOINLESS, sm,
|
||||
this, fetch) > 0)
|
||||
fms[j].select(sel, null, this, fetchState,
|
||||
fetch.EAGER_NONE);
|
||||
if (fms[j].supportsSelect(sel, sel.TYPE_JOINLESS, sm, this,
|
||||
fetch) > 0)
|
||||
fms[j]
|
||||
.select(sel, null, this, fetchState, fetch.EAGER_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1237,8 +1226,8 @@ public class JDBCStoreManager
|
|||
// join down to base class where the conditions will be added
|
||||
ClassMapping from = mapping;
|
||||
ClassMapping sup = mapping.getJoinablePCSuperclassMapping();
|
||||
for (; sup != null; from = sup,
|
||||
sup = from.getJoinablePCSuperclassMapping()) {
|
||||
for (; sup != null; from = sup, sup = from
|
||||
.getJoinablePCSuperclassMapping()) {
|
||||
if (from.getTable() != sup.getTable()) {
|
||||
if (joins == null)
|
||||
joins = sel.newJoins();
|
||||
|
@ -1273,8 +1262,7 @@ public class JDBCStoreManager
|
|||
* Connection returned to client code. Makes sure its wrapped connection
|
||||
* ref count is decremented on finalize.
|
||||
*/
|
||||
private static class ClientConnection
|
||||
extends DelegatingConnection {
|
||||
private static class ClientConnection extends DelegatingConnection {
|
||||
|
||||
private boolean _closed = false;
|
||||
|
||||
|
@ -1282,14 +1270,12 @@ public class JDBCStoreManager
|
|||
super(conn);
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws SQLException {
|
||||
public void close() throws SQLException {
|
||||
_closed = true;
|
||||
super.close();
|
||||
}
|
||||
|
||||
protected void finalize()
|
||||
throws SQLException {
|
||||
protected void finalize() throws SQLException {
|
||||
if (!_closed)
|
||||
close();
|
||||
}
|
||||
|
@ -1299,8 +1285,7 @@ public class JDBCStoreManager
|
|||
* Connection wrapper that keeps an internal ref count so that it knows
|
||||
* when to really close.
|
||||
*/
|
||||
private class RefCountConnection
|
||||
extends DelegatingConnection {
|
||||
private class RefCountConnection extends DelegatingConnection {
|
||||
|
||||
private boolean _retain = false;
|
||||
private int _refs = 0;
|
||||
|
@ -1325,8 +1310,7 @@ public class JDBCStoreManager
|
|||
_refs++;
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws SQLException {
|
||||
public void close() throws SQLException {
|
||||
// lock at broker level to avoid deadlocks
|
||||
_ctx.lock();
|
||||
try {
|
||||
|
@ -1354,30 +1338,27 @@ public class JDBCStoreManager
|
|||
_conn = null;
|
||||
}
|
||||
|
||||
protected Statement createStatement(boolean wrap)
|
||||
throws SQLException {
|
||||
protected Statement createStatement(boolean wrap) throws SQLException {
|
||||
return new CancelStatement(super.createStatement(false),
|
||||
RefCountConnection.this);
|
||||
}
|
||||
|
||||
protected Statement createStatement(int rsType, int rsConcur,
|
||||
boolean wrap)
|
||||
throws SQLException {
|
||||
return new CancelStatement(super.createStatement(rsType,
|
||||
rsConcur, false), RefCountConnection.this);
|
||||
boolean wrap) throws SQLException {
|
||||
return new CancelStatement(super.createStatement(rsType, rsConcur,
|
||||
false), RefCountConnection.this);
|
||||
}
|
||||
|
||||
protected PreparedStatement prepareStatement(String sql, boolean wrap)
|
||||
throws SQLException {
|
||||
return new CancelPreparedStatement(super.prepareStatement
|
||||
(sql, false), RefCountConnection.this);
|
||||
return new CancelPreparedStatement(super.prepareStatement(sql,
|
||||
false), RefCountConnection.this);
|
||||
}
|
||||
|
||||
protected PreparedStatement prepareStatement(String sql, int rsType,
|
||||
int rsConcur, boolean wrap)
|
||||
throws SQLException {
|
||||
return new CancelPreparedStatement(super.prepareStatement
|
||||
(sql, rsType, rsConcur, false), RefCountConnection.this);
|
||||
int rsConcur, boolean wrap) throws SQLException {
|
||||
return new CancelPreparedStatement(super.prepareStatement(sql,
|
||||
rsType, rsConcur, false), RefCountConnection.this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1385,15 +1366,13 @@ public class JDBCStoreManager
|
|||
* Statement type that adds and removes itself from the set of active
|
||||
* statements so that it can be canceled.
|
||||
*/
|
||||
private class CancelStatement
|
||||
extends DelegatingStatement {
|
||||
private class CancelStatement extends DelegatingStatement {
|
||||
|
||||
public CancelStatement(Statement stmnt, Connection conn) {
|
||||
super(stmnt, conn);
|
||||
}
|
||||
|
||||
public int executeUpdate(String sql)
|
||||
throws SQLException {
|
||||
public int executeUpdate(String sql) throws SQLException {
|
||||
beforeExecuteStatement(this);
|
||||
try {
|
||||
return super.executeUpdate(sql);
|
||||
|
@ -1417,16 +1396,13 @@ public class JDBCStoreManager
|
|||
* Statement type that adds and removes itself from the set of active
|
||||
* statements so that it can be canceled.
|
||||
*/
|
||||
private class CancelPreparedStatement
|
||||
extends DelegatingPreparedStatement {
|
||||
private class CancelPreparedStatement extends DelegatingPreparedStatement {
|
||||
|
||||
public CancelPreparedStatement(PreparedStatement stmnt,
|
||||
Connection conn) {
|
||||
public CancelPreparedStatement(PreparedStatement stmnt, Connection conn) {
|
||||
super(stmnt, conn);
|
||||
}
|
||||
|
||||
public int executeUpdate()
|
||||
throws SQLException {
|
||||
public int executeUpdate() throws SQLException {
|
||||
beforeExecuteStatement(this);
|
||||
try {
|
||||
return super.executeUpdate();
|
||||
|
@ -1435,8 +1411,7 @@ public class JDBCStoreManager
|
|||
}
|
||||
}
|
||||
|
||||
protected ResultSet executeQuery(boolean wrap)
|
||||
throws SQLException {
|
||||
protected ResultSet executeQuery(boolean wrap) throws SQLException {
|
||||
beforeExecuteStatement(this);
|
||||
try {
|
||||
return super.executeQuery(wrap);
|
||||
|
@ -1445,8 +1420,7 @@ public class JDBCStoreManager
|
|||
}
|
||||
}
|
||||
|
||||
public int[] executeBatch()
|
||||
throws SQLException {
|
||||
public int[] executeBatch() throws SQLException {
|
||||
beforeExecuteStatement(this);
|
||||
try {
|
||||
return super.executeBatch();
|
||||
|
|
|
@ -65,7 +65,7 @@ import serp.util.Numbers;
|
|||
* @author Abe White
|
||||
* @nojavadoc
|
||||
*/
|
||||
public class JDBCStoreQuery
|
||||
public class JDBCStoreQuery
|
||||
extends ExpressionStoreQuery {
|
||||
|
||||
private static final Table INVALID = new Table();
|
||||
|
@ -107,8 +107,8 @@ public class JDBCStoreQuery
|
|||
}
|
||||
|
||||
public Object newCompilationKey() {
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration)
|
||||
ctx.getFetchConfiguration();
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) ctx
|
||||
.getFetchConfiguration();
|
||||
return Numbers.valueOf(fetch.getJoinSyntax());
|
||||
}
|
||||
|
||||
|
@ -116,10 +116,10 @@ public class JDBCStoreQuery
|
|||
return true;
|
||||
}
|
||||
|
||||
protected ClassMetaData[] getIndependentExpressionCandidates
|
||||
(ClassMetaData meta, boolean subclasses) {
|
||||
protected ClassMetaData[] getIndependentExpressionCandidates(
|
||||
ClassMetaData meta, boolean subclasses) {
|
||||
if (!subclasses)
|
||||
return new ClassMapping[]{ (ClassMapping) meta };
|
||||
return new ClassMapping[] { (ClassMapping) meta };
|
||||
return ((ClassMapping) meta).getIndependentAssignableMappings();
|
||||
}
|
||||
|
||||
|
@ -132,12 +132,12 @@ public class JDBCStoreQuery
|
|||
ExpressionFactory[] facts, QueryExpressions[] exps, Object[] params,
|
||||
boolean lrs, long startIdx, long endIdx) {
|
||||
if (metas.length > 1 && exps[0].aggregate)
|
||||
throw new UserException(Localizer.forPackage(JDBCStoreQuery.class).
|
||||
get("mult-mapping-aggregate", Arrays.asList(metas)));
|
||||
throw new UserException(Localizer.forPackage(JDBCStoreQuery.class)
|
||||
.get("mult-mapping-aggregate", Arrays.asList(metas)));
|
||||
|
||||
ClassMapping[] mappings = (ClassMapping[]) metas;
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration)
|
||||
ctx.getFetchConfiguration();
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) ctx
|
||||
.getFetchConfiguration();
|
||||
JDBCFetchState fetchState = (JDBCFetchState) fetch.newFetchState();
|
||||
if (exps[0].fetchPaths != null) {
|
||||
fetch.addFields(Arrays.asList(exps[0].fetchPaths));
|
||||
|
@ -147,8 +147,8 @@ public class JDBCStoreQuery
|
|||
int eager = calculateEagerMode(exps[0], startIdx, endIdx);
|
||||
int subclassMode = fetch.getSubclassFetchMode((ClassMapping) base);
|
||||
DBDictionary dict = _store.getDBDictionary();
|
||||
long start = (mappings.length == 1 && dict.supportsSelectStartIndex)
|
||||
? startIdx : 0L;
|
||||
long start = (mappings.length == 1 && dict.supportsSelectStartIndex) ? startIdx
|
||||
: 0L;
|
||||
long end = (dict.supportsSelectEndIndex) ? endIdx : Long.MAX_VALUE;
|
||||
|
||||
// add selects with populate WHERE conditions to list
|
||||
|
@ -157,24 +157,25 @@ public class JDBCStoreQuery
|
|||
BitSet subclassBits = new BitSet();
|
||||
BitSet nextBits = new BitSet();
|
||||
boolean unionable = createWhereSelects(sels, mappings, selMappings,
|
||||
subclasses, subclassBits, nextBits, facts, exps, params, fetchState,
|
||||
subclassMode)
|
||||
subclasses, subclassBits, nextBits, facts, exps, params,
|
||||
fetchState, subclassMode)
|
||||
&& subclassMode == JDBCFetchConfiguration.EAGER_JOIN
|
||||
&& start == 0 && end == Long.MAX_VALUE;
|
||||
&& start == 0
|
||||
&& end == Long.MAX_VALUE;
|
||||
|
||||
// we might want to use lrs settings if we can't use the range
|
||||
if (sels.size() > 1)
|
||||
start = 0L;
|
||||
lrs = lrs || (fetch.getFetchBatchSize() >= 0
|
||||
&& (start != startIdx || end != endIdx));
|
||||
lrs = lrs
|
||||
|| (fetch.getFetchBatchSize() >= 0 && (start != startIdx || end != endIdx));
|
||||
|
||||
ResultObjectProvider[] rops = null;
|
||||
ResultObjectProvider rop = null;
|
||||
if (unionable) {
|
||||
Union union = _store.getSQLFactory().newUnion((Select[])
|
||||
sels.toArray(new Select[sels.size()]));
|
||||
BitSet[] paged = populateUnion(union, mappings, subclasses,
|
||||
facts, exps, params, fetchState, lrs, eager, start, end);
|
||||
Union union = _store.getSQLFactory().newUnion(
|
||||
(Select[]) sels.toArray(new Select[sels.size()]));
|
||||
BitSet[] paged = populateUnion(union, mappings, subclasses, facts,
|
||||
exps, params, fetchState, lrs, eager, start, end);
|
||||
union.setLRS(lrs);
|
||||
rop = executeUnion(union, mappings, exps, paged, fetchState);
|
||||
} else {
|
||||
|
@ -209,8 +210,8 @@ public class JDBCStoreQuery
|
|||
}
|
||||
|
||||
// need to fake result range?
|
||||
if ((rops != null && endIdx != Long.MAX_VALUE)
|
||||
|| start != startIdx || end != endIdx)
|
||||
if ((rops != null && endIdx != Long.MAX_VALUE) || start != startIdx
|
||||
|| end != endIdx)
|
||||
rop = new RangeResultObjectProvider(rop, startIdx, endIdx);
|
||||
return rop;
|
||||
}
|
||||
|
@ -226,6 +227,7 @@ public class JDBCStoreQuery
|
|||
final BitSet[] paged = (exps[0].projections.length > 0) ? null
|
||||
: new BitSet[mappings.length];
|
||||
union.select(new Union.Selector() {
|
||||
|
||||
public void select(Select sel, int idx) {
|
||||
BitSet bits = populateSelect(sel, mappings[idx], subclasses,
|
||||
(JDBCExpressionFactory) facts[idx], exps[idx], params,
|
||||
|
@ -267,8 +269,8 @@ public class JDBCStoreQuery
|
|||
ClassMapping[] mappings, QueryExpressions[] exps, BitSet[] paged,
|
||||
JDBCFetchState fetchState) {
|
||||
if (exps[0].projections.length > 0)
|
||||
return new ProjectionResultObjectProvider(union, _store, fetchState,
|
||||
exps);
|
||||
return new ProjectionResultObjectProvider(union, _store,
|
||||
fetchState, exps);
|
||||
|
||||
if (paged != null)
|
||||
for (int i = 0; i < paged.length; i++)
|
||||
|
@ -341,11 +343,11 @@ public class JDBCStoreQuery
|
|||
private ClassMapping[] getVerticalMappings(ClassMapping mapping,
|
||||
boolean subclasses, QueryExpressions exps, int subclassMode) {
|
||||
if (!subclasses || exps.projections.length > 0)
|
||||
return new ClassMapping[]{ mapping };
|
||||
return new ClassMapping[] { mapping };
|
||||
|
||||
if (subclassMode != JDBCFetchConfiguration.EAGER_PARALLEL
|
||||
|| !hasVerticalSubclasses(mapping))
|
||||
return new ClassMapping[]{ mapping };
|
||||
return new ClassMapping[] { mapping };
|
||||
|
||||
List subs = new ArrayList(4);
|
||||
addSubclasses(mapping, subs);
|
||||
|
@ -382,7 +384,7 @@ public class JDBCStoreQuery
|
|||
private static boolean hasVerticalSubclasses(ClassMapping mapping) {
|
||||
ClassMapping[] subs = mapping.getJoinablePCSubclassMappings();
|
||||
for (int i = 0; i < subs.length; i++)
|
||||
if (subs[i].getStrategy()instanceof VerticalClassStrategy)
|
||||
if (subs[i].getStrategy() instanceof VerticalClassStrategy)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -405,15 +407,15 @@ public class JDBCStoreQuery
|
|||
protected Number executeDelete(Executor ex, ClassMetaData base,
|
||||
ClassMetaData[] metas, boolean subclasses, ExpressionFactory[] facts,
|
||||
QueryExpressions[] exps, Object[] params) {
|
||||
return executeBulkOperation(ex, base, metas, subclasses, facts,
|
||||
exps, params, null);
|
||||
return executeBulkOperation(ex, base, metas, subclasses, facts, exps,
|
||||
params, null);
|
||||
}
|
||||
|
||||
protected Number executeUpdate(Executor ex, ClassMetaData base,
|
||||
ClassMetaData[] metas, boolean subclasses, ExpressionFactory[] facts,
|
||||
QueryExpressions[] exps, Object[] params) {
|
||||
return executeBulkOperation(ex, base, metas, subclasses, facts,
|
||||
exps, params, exps[0].updates);
|
||||
return executeBulkOperation(ex, base, metas, subclasses, facts, exps,
|
||||
params, exps[0].updates);
|
||||
}
|
||||
|
||||
private Number executeBulkOperation(Executor ex, ClassMetaData base,
|
||||
|
@ -430,15 +432,15 @@ public class JDBCStoreQuery
|
|||
if (!isUpdate) {
|
||||
// if there are any delete callbacks, we need to
|
||||
// execute in-memory so the callbacks are invoked
|
||||
LifecycleEventManager mgr = ctx.getStoreContext().getBroker().
|
||||
getLifecycleEventManager();
|
||||
LifecycleEventManager mgr = ctx.getStoreContext().getBroker()
|
||||
.getLifecycleEventManager();
|
||||
if (mgr.hasDeleteListeners(null, mappings[i]))
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration)
|
||||
ctx.getFetchConfiguration();
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) ctx
|
||||
.getFetchConfiguration();
|
||||
DBDictionary dict = _store.getDBDictionary();
|
||||
|
||||
SQLBuffer[] sql = new SQLBuffer[mappings.length];
|
||||
|
@ -448,8 +450,8 @@ public class JDBCStoreQuery
|
|||
jdbcFactory = (JDBCExpressionFactory) facts[i];
|
||||
JDBCFetchState fetchState = (JDBCFetchState) fetch.newFetchState();
|
||||
sel = jdbcFactory.evaluate(this, fetchState, exps[i], params);
|
||||
jdbcFactory.select(this, mappings[i], subclasses, sel,
|
||||
exps[i], params, fetchState, JDBCFetchConfiguration.EAGER_NONE);
|
||||
jdbcFactory.select(this, mappings[i], subclasses, sel, exps[i],
|
||||
params, fetchState, JDBCFetchConfiguration.EAGER_NONE);
|
||||
|
||||
// specification of the "udpates" map indicates that this is
|
||||
// an update query; otherwise, this is a delete statement
|
||||
|
@ -487,8 +489,7 @@ public class JDBCStoreQuery
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
} catch (SQLException se) {
|
||||
throw SQLExceptions.getStore(se, ctx, _store.getDBDictionary());
|
||||
} finally {
|
||||
try {
|
||||
|
@ -577,8 +578,8 @@ public class JDBCStoreQuery
|
|||
ClassMetaData[] metas, boolean subclasses, ExpressionFactory[] facts,
|
||||
QueryExpressions[] exps, Object[] params, long startIdx, long endIdx) {
|
||||
ClassMapping[] mappings = (ClassMapping[]) metas;
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration)
|
||||
ctx.getFetchConfiguration();
|
||||
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) ctx
|
||||
.getFetchConfiguration();
|
||||
JDBCFetchState fetchState = (JDBCFetchState) fetch.newFetchState();
|
||||
if (exps[0].fetchPaths != null) {
|
||||
fetch.addFields(Arrays.asList(exps[0].fetchPaths));
|
||||
|
@ -589,8 +590,8 @@ public class JDBCStoreQuery
|
|||
eager = Math.min(eager, JDBCFetchConfiguration.EAGER_JOIN);
|
||||
int subclassMode = fetch.getSubclassFetchMode((ClassMapping) base);
|
||||
DBDictionary dict = _store.getDBDictionary();
|
||||
long start = (mappings.length == 1 && dict.supportsSelectStartIndex)
|
||||
? startIdx : 0L;
|
||||
long start = (mappings.length == 1 && dict.supportsSelectStartIndex) ? startIdx
|
||||
: 0L;
|
||||
long end = (dict.supportsSelectEndIndex) ? endIdx : Long.MAX_VALUE;
|
||||
|
||||
// add selects with populate WHERE conditions to list
|
||||
|
@ -599,20 +600,19 @@ public class JDBCStoreQuery
|
|||
BitSet subclassBits = new BitSet();
|
||||
BitSet nextBits = new BitSet();
|
||||
boolean unionable = createWhereSelects(sels, mappings, selMappings,
|
||||
subclasses, subclassBits, nextBits, facts, exps, params, fetchState,
|
||||
subclassMode)
|
||||
subclasses, subclassBits, nextBits, facts, exps, params,
|
||||
fetchState, subclassMode)
|
||||
&& subclassMode == JDBCFetchConfiguration.EAGER_JOIN;
|
||||
if (sels.size() > 1)
|
||||
start = 0L;
|
||||
|
||||
if (unionable) {
|
||||
Union union = _store.getSQLFactory().newUnion((Select[])
|
||||
sels.toArray(new Select[sels.size()]));
|
||||
Union union = _store.getSQLFactory().newUnion(
|
||||
(Select[]) sels.toArray(new Select[sels.size()]));
|
||||
populateUnion(union, mappings, subclasses, facts, exps, params,
|
||||
fetchState, false, eager, start, end);
|
||||
if (union.isUnion())
|
||||
return new String[]{ union.toSelect(false, fetch).
|
||||
getSQL(true) };
|
||||
return new String[] { union.toSelect(false, fetch).getSQL(true) };
|
||||
sels = Arrays.asList(union.getSelects());
|
||||
} else {
|
||||
Select sel;
|
||||
|
@ -628,8 +628,7 @@ public class JDBCStoreQuery
|
|||
|
||||
String[] sql = new String[sels.size()];
|
||||
for (int i = 0; i < sels.size(); i++)
|
||||
sql[i] = ((Select) sels.get(i)).toSelect(false, fetch).
|
||||
getSQL(true);
|
||||
sql[i] = ((Select) sels.get(i)).toSelect(false, fetch).getSQL(true);
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,11 +37,11 @@ import org.apache.openjpa.util.OptimisticException;
|
|||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
class PreparedStatementManagerImpl
|
||||
class PreparedStatementManagerImpl
|
||||
implements PreparedStatementManager {
|
||||
|
||||
private final static Localizer _loc = Localizer.forPackage
|
||||
(PreparedStatementManagerImpl.class);
|
||||
private final static Localizer _loc = Localizer
|
||||
.forPackage(PreparedStatementManagerImpl.class);
|
||||
|
||||
private final JDBCStore _store;
|
||||
private final Connection _conn;
|
||||
|
@ -76,8 +76,7 @@ class PreparedStatementManagerImpl
|
|||
/**
|
||||
* Flush the given row.
|
||||
*/
|
||||
private void flushInternal(RowImpl row)
|
||||
throws SQLException {
|
||||
private void flushInternal(RowImpl row) throws SQLException {
|
||||
// can't batch rows with auto-inc columns
|
||||
Column[] autoAssign = null;
|
||||
if (row.getAction() == Row.ACTION_INSERT)
|
||||
|
@ -96,12 +95,11 @@ class PreparedStatementManagerImpl
|
|||
if (failed != null)
|
||||
_exceptions.add(new OptimisticException(failed));
|
||||
else if (row.getAction() == Row.ACTION_INSERT)
|
||||
throw new SQLException(_loc.get
|
||||
("update-failed-no-failed-obj", String.valueOf(count),
|
||||
sql));
|
||||
throw new SQLException(_loc.get(
|
||||
"update-failed-no-failed-obj", String.valueOf(count),
|
||||
sql));
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
} catch (SQLException se) {
|
||||
throw SQLExceptions.getStore(se, row.getFailedObject(), _dict);
|
||||
} finally {
|
||||
try {
|
||||
|
@ -118,8 +116,8 @@ class PreparedStatementManagerImpl
|
|||
Object val;
|
||||
for (int i = 0; i < autoAssign.length; i++) {
|
||||
val = _dict.getGeneratedKey(autoAssign[i], _conn);
|
||||
mapping.assertJoinable(autoAssign[i]).setAutoAssignedValue
|
||||
(sm, _store, autoAssign[i], val);
|
||||
mapping.assertJoinable(autoAssign[i]).setAutoAssignedValue(sm,
|
||||
_store, autoAssign[i], val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,8 +166,7 @@ public abstract class AbstractTestCase extends TestCase {
|
|||
_watchdog.enteringTest(this);
|
||||
try {
|
||||
super.run(result);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
_watchdog.leavingTest(this);
|
||||
}
|
||||
}
|
||||
|
@ -530,8 +529,7 @@ public abstract class AbstractTestCase extends TestCase {
|
|||
meth.invoke(thiz, args);
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
multiThreadExecuting = null;
|
||||
}
|
||||
}
|
||||
|
@ -806,8 +804,7 @@ public abstract class AbstractTestCase extends TestCase {
|
|||
method.invoke(thz, (Object[]) null);
|
||||
} catch (Throwable t) {
|
||||
throwable = t;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
completed = true;
|
||||
}
|
||||
}
|
||||
|
@ -846,8 +843,7 @@ public abstract class AbstractTestCase extends TestCase {
|
|||
|
||||
// I guess everything was OK
|
||||
return true;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
inTimeoutThread = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1074,8 +1074,7 @@ public class XMLPersistenceMetaDataParser
|
|||
member = meta.getDescribedType().getDeclaredField(name);
|
||||
type = ((Field) member).getType();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
throw getException(_loc.get("invalid-attr", name, meta), e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue