本文整理匯總了Java中com.j256.ormlite.dao.BaseForeignCollection類的典型用法代碼示例。如果您正苦於以下問題:Java BaseForeignCollection類的具體用法?Java BaseForeignCollection怎麽用?Java BaseForeignCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BaseForeignCollection類屬於com.j256.ormlite.dao包,在下文中一共展示了BaseForeignCollection類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildForeignCollection
import com.j256.ormlite.dao.BaseForeignCollection; //導入依賴的package包/類
public <FT, FID> BaseForeignCollection<FT, FID> buildForeignCollection(Object paramObject, FID paramFID)
{
if (this.foreignFieldType == null)
return null;
BaseDaoImpl localBaseDaoImpl = this.foreignDao;
if (!this.fieldConfig.isForeignCollectionEager())
return new LazyForeignCollection(localBaseDaoImpl, paramObject, paramFID, this.foreignFieldType, this.fieldConfig.getForeignCollectionOrderColumnName(), this.fieldConfig.isForeignCollectionOrderAscending());
LevelCounters localLevelCounters = (LevelCounters)threadLevelCounters.get();
if (localLevelCounters.foreignCollectionLevel == 0)
localLevelCounters.foreignCollectionLevelMax = this.fieldConfig.getForeignCollectionMaxEagerLevel();
if (localLevelCounters.foreignCollectionLevel >= localLevelCounters.foreignCollectionLevelMax)
return new LazyForeignCollection(localBaseDaoImpl, paramObject, paramFID, this.foreignFieldType, this.fieldConfig.getForeignCollectionOrderColumnName(), this.fieldConfig.isForeignCollectionOrderAscending());
localLevelCounters.foreignCollectionLevel = (1 + localLevelCounters.foreignCollectionLevel);
try
{
EagerForeignCollection localEagerForeignCollection = new EagerForeignCollection(localBaseDaoImpl, paramObject, paramFID, this.foreignFieldType, this.fieldConfig.getForeignCollectionOrderColumnName(), this.fieldConfig.isForeignCollectionOrderAscending());
return localEagerForeignCollection;
}
finally
{
localLevelCounters.foreignCollectionLevel = (-1 + localLevelCounters.foreignCollectionLevel);
}
}
示例2: refreshForeignCollection
import com.j256.ormlite.dao.BaseForeignCollection; //導入依賴的package包/類
public void refreshForeignCollection(BaseForeignCollection collection) {
if(collection!=null) {
try {
collection.refreshCollection();
collection.refreshAll();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例3: mapRow
import com.j256.ormlite.dao.BaseForeignCollection; //導入依賴的package包/類
public T mapRow(DatabaseResults paramDatabaseResults)
{
Object localObject1;
if (this.columnPositions == null)
localObject1 = new HashMap();
else
localObject1 = this.columnPositions;
ObjectCache localObjectCache = paramDatabaseResults.getObjectCache();
if (localObjectCache != null)
{
Object localObject5 = this.idField.resultToJava(paramDatabaseResults, (Map)localObject1);
Object localObject6 = localObjectCache.get(this.clazz, localObject5);
if (localObject6 != null)
return localObject6;
}
Object localObject2 = this.tableInfo.createObject();
Object localObject3 = null;
int i = 0;
for (FieldType localFieldType2 : this.resultsFieldTypes)
if (localFieldType2.isForeignCollection())
{
i = 1;
}
else
{
Object localObject4 = localFieldType2.resultToJava(paramDatabaseResults, (Map)localObject1);
if ((localObject4 != null) && (this.parent != null) && (localFieldType2.getField().getType() == this.parent.getClass()) && (localObject4.equals(this.parentId)))
localFieldType2.assignField(localObject2, this.parent, true, localObjectCache);
else
localFieldType2.assignField(localObject2, localObject4, false, localObjectCache);
if (localFieldType2 == this.idField)
localObject3 = localObject4;
}
if (i != 0)
for (FieldType localFieldType1 : this.resultsFieldTypes)
if (localFieldType1.isForeignCollection())
{
BaseForeignCollection localBaseForeignCollection = localFieldType1.buildForeignCollection(localObject2, localObject3);
if (localBaseForeignCollection != null)
localFieldType1.assignField(localObject2, localBaseForeignCollection, false, localObjectCache);
}
if ((localObjectCache != null) && (localObject3 != null))
localObjectCache.put(this.clazz, localObject3, localObject2);
if (this.columnPositions == null)
this.columnPositions = ((Map)localObject1);
return localObject2;
}
示例4: buildForeignCollection
import com.j256.ormlite.dao.BaseForeignCollection; //導入依賴的package包/類
/**
* Build and return a foreign collection based on the field settings that matches the id argument. This can return
* null in certain circumstances.
*
* @param parent
* The parent object that we will set on each item in the collection.
* @param id
* The id of the foreign object we will look for. This can be null if we are creating an empty
* collection.
*/
public <FT, FID> BaseForeignCollection<FT, FID> buildForeignCollection(Object parent, FID id) throws SQLException {
// this can happen if we have a foreign-auto-refresh scenario
if (foreignFieldType == null) {
return null;
}
@SuppressWarnings("unchecked")
Dao<FT, FID> castDao = (Dao<FT, FID>) foreignDao;
if (!fieldConfig.isForeignCollectionEager()) {
// we know this won't go recursive so no need for the counters
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
}
// try not to create level counter objects unless we have to
LevelCounters levelCounters = threadLevelCounters.get();
if (levelCounters == null) {
if (fieldConfig.getForeignCollectionMaxEagerLevel() == 0) {
// then return a lazy collection instead
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(),
fieldConfig.isForeignCollectionOrderAscending());
}
levelCounters = new LevelCounters();
threadLevelCounters.set(levelCounters);
}
if (levelCounters.foreignCollectionLevel == 0) {
levelCounters.foreignCollectionLevelMax = fieldConfig.getForeignCollectionMaxEagerLevel();
}
// are we over our level limit?
if (levelCounters.foreignCollectionLevel >= levelCounters.foreignCollectionLevelMax) {
// then return a lazy collection instead
return new LazyForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
}
levelCounters.foreignCollectionLevel++;
try {
return new EagerForeignCollection<FT, FID>(castDao, parent, id, foreignFieldType,
fieldConfig.getForeignCollectionOrderColumnName(), fieldConfig.isForeignCollectionOrderAscending());
} finally {
levelCounters.foreignCollectionLevel--;
}
}