本文整理汇总了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();
}