本文整理匯總了Java中com.j256.ormlite.dao.DaoManager.clearCache方法的典型用法代碼示例。如果您正苦於以下問題:Java DaoManager.clearCache方法的具體用法?Java DaoManager.clearCache怎麽用?Java DaoManager.clearCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.j256.ormlite.dao.DaoManager
的用法示例。
在下文中一共展示了DaoManager.clearCache方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: before
import com.j256.ormlite.dao.DaoManager; //導入方法依賴的package包/類
@Before
public void before() throws Exception {
DaoManager.clearCache();
if (connectionSource != null) {
return;
}
// do this for everyone
System.setProperty("derby.stream.error.file", "target/derby.log");
setDatabaseParams();
doOpenConnectionSource();
}
示例2: after
import com.j256.ormlite.dao.DaoManager; //導入方法依賴的package包/類
@After
public void after() throws Exception {
if (connectionSource != null) {
for (Class<?> clazz : dropClassSet) {
dropTable(clazz, true);
}
dropClassSet.clear();
for (DatabaseTableConfig<?> tableConfig : dropTableConfigSet) {
dropTable(tableConfig, true);
}
dropTableConfigSet.clear();
}
closeConnectionSource();
DaoManager.clearCache();
}
示例3: testForeignDaos
import com.j256.ormlite.dao.DaoManager; //導入方法依賴的package包/類
public void testForeignDaos() throws Exception {
DaoManager.clearCache();
assertNull(DaoManager.lookupDao(connectionSource, Foo.class));
assertNull(DaoManager.lookupDao(connectionSource, Foreign.class));
Dao<Foo, Object> fooDao1 = createDao(Foo.class, true);
Dao<Foo, ?> fooDao2 = DaoManager.lookupDao(connectionSource, Foo.class);
assertSame(fooDao1, fooDao2);
Dao<Foreign, Integer> foreignDao1 = DaoManager.lookupDao(connectionSource, Foreign.class);
assertNotNull(foreignDao1);
Dao<Foreign, Integer> foreignDao2 = DaoManager.createDao(connectionSource, Foreign.class);
assertSame(foreignDao1, foreignDao2);
}
示例4: testForeignDaoTableConfig
import com.j256.ormlite.dao.DaoManager; //導入方法依賴的package包/類
public void testForeignDaoTableConfig() throws Exception {
DaoManager.clearCache();
assertNull(DaoManager.lookupDao(connectionSource, Foo.class));
assertNull(DaoManager.lookupDao(connectionSource, Foreign.class));
DatabaseFieldConfig fieldConfig = new DatabaseFieldConfig("id");
fieldConfig.setGeneratedId(true);
DatabaseTableConfig<Foo> tableConfig = new DatabaseTableConfig<Foo>(Foo.class, Arrays.asList(fieldConfig));
Dao<Foo, Object> fooDao1 = createDao(tableConfig, true);
Dao<Foo, ?> fooDao2 = DaoManager.lookupDao(connectionSource, Foo.class);
assertSame(fooDao1, fooDao2);
assertNull(DaoManager.lookupDao(connectionSource, Foreign.class));
}
示例5: close
import com.j256.ormlite.dao.DaoManager; //導入方法依賴的package包/類
@Override
public void close() {
super.close();
DaoManager.clearCache();
}
示例6: testDaoCache
import com.j256.ormlite.dao.DaoManager; //導入方法依賴的package包/類
public void testDaoCache() throws Exception {
start();
TableUtils.dropTable(connectionSource, Account.class, true);
TableUtils.createTable(connectionSource, Account.class);
TableUtils.dropTable(connectionSource, Order.class, true);
TableUtils.createTable(connectionSource, Order.class);
accountDao = helper.getDao(Account.class);
accountDao.setObjectCache(true);
orderDao = helper.getDao(Order.class);
orderDao.setObjectCache(true);
String accountName = "account";
Account account = new Account(accountName);
assertEquals(1, accountDao.create(account));
Account account1 = accountDao.queryForId(accountName);
assertNotSame(account, account1);
String orderName = "order1";
Order order = new Order(orderName);
order.account = account1;
assertEquals(1, orderDao.create(order));
Account account2 = accountDao.queryForId(accountName);
assertSame(account1, account2);
Order order1 = account1.getOrders().get(0);
assertEquals(order, order1);
Order order2 = orderDao.queryForId(orderName);
assertSame(order, order2);
assertSame(order1, order2);
stop();
DaoManager.clearCache();
// accountDao.clearObjectCache();
// orderDao.clearObjectCache();
BaseDaoImpl.clearAllInternalObjectCaches();
start();
accountDao = helper.getDao(Account.class);
accountDao.setObjectCache(true);
orderDao = helper.getDao(Order.class);
orderDao.setObjectCache(true);
Account account3 = accountDao.queryForId(accountName);
assertNotSame(account, account3);
assertNotSame(account1, account3);
assertNotSame(account2, account3);
Order order3 = orderDao.queryForId(orderName);
assertNotNull(order3);
assertNotSame(order, order3);
assertNotSame(order1, order3);
assertNotSame(order2, order3);
Order order4 = account3.getOrders().get(0);
assertNotNull(order4);
assertNotSame(order, order4);
assertNotSame(order1, order4);
assertNotSame(order2, order4);
assertSame(order4, order3);
Order order5 = orderDao.queryForId(orderName);
assertSame(order3, order5);
stop();
}
示例7: before
import com.j256.ormlite.dao.DaoManager; //導入方法依賴的package包/類
@Before
public void before() throws Exception {
connectionSource = new WrappedConnectionSource(new H2ConnectionSource());
databaseType = connectionSource.getDatabaseType();
DaoManager.clearCache();
}