/** * Clone this instance. */ public Object clone() { FetchConfigurationImpl clone = newInstance(null); clone._state.ctx = _state.ctx; clone._state.cacheNonDefaultFetchPlanQueries = _state.cacheNonDefaultFetchPlanQueries; clone._parent = _parent; clone._fromField = _fromField; clone._fromType = _fromType; clone._directRelationOwner = _directRelationOwner; clone._load = _load; clone._availableRecursion = _availableRecursion; clone._availableDepth = _availableDepth; clone.copy(this); return clone; }
/** * Return a new hollow instance. */ protected FetchConfigurationImpl newInstance(ConfigurationState state) { return new FetchConfigurationImpl(state); }
public FetchConfiguration addFetchGroups(Collection<String> groups) { if (groups == null || groups.isEmpty()) return this; for (String group : groups) addFetchGroup(group, false); verifyDefaultPUFetchGroups(); return this; }
public FetchConfiguration resetFetchGroups() { String[] fetchGroupList = _state.ctx.getConfiguration().getFetchGroupsList(); clearFetchGroups((fetchGroupList == null || fetchGroupList.length == 0)); if (_state.ctx != null) addFetchGroups(Arrays.asList(fetchGroupList)); verifyDefaultPUFetchGroups(); return this; }
public void copy(FetchConfiguration fetch) { setFetchBatchSize(fetch.getFetchBatchSize()); setMaxFetchDepth(fetch.getMaxFetchDepth()); setQueryCacheEnabled(fetch.getQueryCacheEnabled()); setFlushBeforeQueries(fetch.getFlushBeforeQueries()); setExtendedPathLookup(fetch.getExtendedPathLookup()); setLockTimeout(fetch.getLockTimeout()); setQueryTimeout(fetch.getQueryTimeout()); setLockScope(fetch.getLockScope()); clearFetchGroups(false); addFetchGroups(fetch.getFetchGroups()); clearFields(); copyHints(fetch); setCacheRetrieveMode(fetch.getCacheRetrieveMode()); setCacheStoreMode(fetch.getCacheStoreMode()); addFields(fetch.getFields()); // don't use setters because require active transaction _state.readLockLevel = fetch.getReadLockLevel(); _state.writeLockLevel = fetch.getWriteLockLevel(); }
public void setContext(StoreContext ctx) { // can't reset non-null context to another context if (ctx != null && _state.ctx != null && ctx != _state.ctx) throw new InternalException(); _state.ctx = ctx; if (ctx == null) return; // initialize to conf info OpenJPAConfiguration conf = ctx.getConfiguration(); setFetchBatchSize(conf.getFetchBatchSize()); setFlushBeforeQueries(conf.getFlushBeforeQueriesConstant()); setLockTimeout(conf.getLockTimeout()); clearFetchGroups(); addFetchGroups(Arrays.asList(conf.getFetchGroupsList())); setMaxFetchDepth(conf.getMaxFetchDepth()); }
public void copy(FetchConfiguration fetch) { setFetchBatchSize(fetch.getFetchBatchSize()); setMaxFetchDepth(fetch.getMaxFetchDepth()); setQueryCacheEnabled(fetch.getQueryCacheEnabled()); setFlushBeforeQueries(fetch.getFlushBeforeQueries()); setLockTimeout(fetch.getLockTimeout()); clearFetchGroups(); addFetchGroups(fetch.getFetchGroups()); clearFields(); addFields(fetch.getFields()); // don't use setters because require active transaction _state.readLockLevel = fetch.getReadLockLevel(); _state.writeLockLevel = fetch.getWriteLockLevel(); }
public FetchConfiguration setWriteLockLevel(int level) { if (_state.ctx == null) return this; lock(); try { assertActiveTransaction(); if (level == DEFAULT) _state.writeLockLevel = _state.ctx.getConfiguration(). getWriteLockLevelConstant(); else _state.writeLockLevel = level; } finally { unlock(); } return this; }
public FetchConfiguration traverse(FieldMetaData fm) { Class<?> type = fm.getRelationType(); if (type == null) return this; FetchConfigurationImpl clone = newInstance(_state); clone._parent = this; clone._availableDepth = reduce(_availableDepth); clone._fromField = fm.getFullName(false); clone._fromType = type; clone._availableRecursion = getAvailableRecursionDepth(fm, type, fm.getFullName(false), true); if (Objects.equals(_directRelationOwner, fm.getFullName(false))) clone._load = false; else clone._load = _load; FieldMetaData owner = fm.getMappedByMetaData(); if (owner != null && owner.getTypeCode() == JavaTypes.PC) clone._directRelationOwner = owner.getFullName(false); return clone; }
private String getPathString() { List<FetchConfigurationImpl> path = getPath(); if (path.isEmpty()) return ""; StringBuilder buf = new StringBuilder().append (": "); for (Iterator<FetchConfigurationImpl> itr = path.iterator(); itr.hasNext();) { buf.append(itr.next().getTraversedFromField()); if (itr.hasNext()) buf.append("->"); } return buf.toString(); }
public FetchConfiguration traverse(FieldMetaData fm) { Class type = getRelationType(fm); if (type == null) return this; FetchConfigurationImpl clone = newInstance(_state); clone._parent = this; clone._availableDepth = reduce(_availableDepth); clone._fromField = fm.getFullName(false); clone._fromType = type; clone._availableRecursion = getAvailableRecursionDepth(fm, type, true); if (StringUtils.equals(_directRelationOwner, fm.getFullName())) clone._load = false; else clone._load = _load; FieldMetaData owner = fm.getMappedByMetaData(); if (owner != null && owner.getTypeCode() == JavaTypes.PC) clone._directRelationOwner = owner.getFullName(); return clone; }
public int requiresFetch(FieldMetaData fm) { if (!includes(fm)) return FETCH_NONE; Class<?> type = fm.getRelationType(); if (type == null) return FETCH_LOAD; if (_availableDepth == 0) return FETCH_NONE; // we can skip calculating recursion depth if this is a top-level conf: // the field is in our fetch groups, so can't possibly not select if (_parent == null) return FETCH_LOAD; String fieldName = fm.getFullName(false); int rdepth = getAvailableRecursionDepth(fm, type, fieldName, false); if (rdepth != FetchGroup.DEPTH_INFINITE && rdepth <= 0) return FETCH_NONE; if (Objects.equals(_directRelationOwner, fieldName)) return FETCH_REF; return FETCH_LOAD; }
public void copy(FetchConfiguration fetch) { super.copy(fetch); JDBCFetchConfiguration jf = (JDBCFetchConfiguration) fetch; setEagerFetchMode(jf.getEagerFetchMode()); setSubclassFetchMode(jf.getSubclassFetchMode()); setResultSetType(jf.getResultSetType()); setFetchDirection(jf.getFetchDirection()); setLRSSize(jf.getLRSSize()); setJoinSyntax(jf.getJoinSyntax()); addJoins(jf.getJoins()); }
public int requiresFetch(FieldMetaData fm) { if (!includes(fm)) return FETCH_NONE; Class type = getRelationType(fm); if (type == null) return FETCH_LOAD; if (_availableDepth == 0) return FETCH_NONE; // we can skip calculating recursion depth if this is a top-level conf: // the field is in our fetch groups, so can't possibly not select if (_parent == null) return FETCH_LOAD; int rdepth = getAvailableRecursionDepth(fm, type, false); if (rdepth != FetchGroup.DEPTH_INFINITE && rdepth <= 0) return FETCH_NONE; if (StringUtils.equals(_directRelationOwner, fm.getFullName())) return FETCH_REF; return FETCH_LOAD; }
public FetchConfiguration resetFetchGroups() { clearFetchGroups(); if (_state.ctx != null) addFetchGroups(Arrays.asList(_state.ctx.getConfiguration(). getFetchGroupsList())); return this; }
public FetchConfiguration addFetchGroup(String name) { return addFetchGroup(name, true); }
public FetchConfiguration clearFetchGroups() { return clearFetchGroups(true); }
public void copy(FetchConfiguration fetch) { setFetchBatchSize(fetch.getFetchBatchSize()); setMaxFetchDepth(fetch.getMaxFetchDepth()); setQueryCacheEnabled(fetch.getQueryCacheEnabled()); setFlushBeforeQueries(fetch.getFlushBeforeQueries()); setExtendedPathLookup(fetch.getExtendedPathLookup()); setLockTimeout(fetch.getLockTimeout()); setQueryTimeout(fetch.getQueryTimeout()); setLockScope(fetch.getLockScope()); clearFetchGroups(false); addFetchGroups(fetch.getFetchGroups()); clearFields(); copyHints(fetch); setCacheRetrieveMode(fetch.getCacheRetrieveMode()); setCacheStoreMode(fetch.getCacheStoreMode()); addFields(fetch.getFields()); // don't use setters because require active transaction _state.readLockLevel = fetch.getReadLockLevel(); _state.writeLockLevel = fetch.getWriteLockLevel(); }
public void setContext(StoreContext ctx) { // can't reset non-null context to another context if (ctx != null && _state.ctx != null && ctx != _state.ctx) throw new InternalException(); _state.ctx = ctx; if (ctx == null) return; // initialize to conf info OpenJPAConfiguration conf = ctx.getConfiguration(); setFetchBatchSize(conf.getFetchBatchSize()); setFlushBeforeQueries(conf.getFlushBeforeQueriesConstant()); setLockTimeout(conf.getLockTimeout()); setQueryTimeout(conf.getQueryTimeout()); String[] fetchGroupList = conf.getFetchGroupsList(); clearFetchGroups((fetchGroupList == null || fetchGroupList.length == 0)); addFetchGroups(Arrays.asList(fetchGroupList)); setMaxFetchDepth(conf.getMaxFetchDepth()); _state.cacheNonDefaultFetchPlanQueries = conf.getCompatibilityInstance().getCacheNonDefaultFetchPlanQueries(); }
public FetchConfiguration setReadLockLevel(int level) { if (_state.ctx == null) return this; lock(); try { assertActiveTransaction(); if (level == DEFAULT) _state.readLockLevel = _state.ctx.getConfiguration(). getReadLockLevelConstant(); else _state.readLockLevel = level; } finally { unlock(); } return this; }