com.j256.ormlite.dao.Dao.setObjectFactory()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中com.j256.ormlite.dao.Dao.setObjectFactory()方法的一些代码示例,展示了Dao.setObjectFactory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.setObjectFactory()方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:setObjectFactory

Dao.setObjectFactory介绍

[英]Set an object factory so we can wire in controls over an object when it is constructed. Set to null to disable the factory.
[中]设置一个对象工厂,这样我们可以在构建对象时将控件连接到对象上。设置为null以禁用工厂。

代码示例

代码示例来源:origin: com.j256.ormlite/ormlite-core

/**
 * @see Dao#setObjectFactory(ObjectFactory)
 */
@Override
public void setObjectFactory(ObjectFactory<T> objectFactory) {
  dao.setObjectFactory(objectFactory);
}

代码示例来源:origin: j256/ormlite-core

/**
 * @see Dao#setObjectFactory(ObjectFactory)
 */
@Override
public void setObjectFactory(ObjectFactory<T> objectFactory) {
  dao.setObjectFactory(objectFactory);
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testObjectFactory() throws Exception {
  Dao<Foo, Object> dao = createDao(Foo.class, true);
  FooFactory fooFactory = new FooFactory();
  dao.setObjectFactory(fooFactory);
  Foo foo = new Foo();
  foo.val = 1231;
  assertEquals(1, dao.create(foo));
  assertEquals(0, fooFactory.fooList.size());
  List<Foo> results = dao.queryForAll();
  assertEquals(1, results.size());
  assertEquals(foo.val, results.get(0).val);
  assertEquals(1, fooFactory.fooList.size());
  results = dao.queryForAll();
  assertEquals(1, results.size());
  assertEquals(foo.val, results.get(0).val);
  assertEquals(2, fooFactory.fooList.size());
}

相关文章