本文整理了Java中com.j256.ormlite.dao.Dao.extractId()
方法的一些代码示例,展示了Dao.extractId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.extractId()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:extractId
[英]Returns the ID from the data parameter passed in. This is used by some of the internal queries to be able to search by id.
[中]从传入的数据参数返回ID。这被一些内部查询用来按id进行搜索。
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#extractId(Object)
*/
@Override
public ID extractId(T data) {
try {
return dao.extractId(data);
} catch (SQLException e) {
logMessage(e, "extractId threw exception on: " + data);
throw new RuntimeException(e);
}
}
代码示例来源:origin: j256/ormlite-core
/**
* A call through to the {@link Dao#extractId(Object)}.
*/
public ID extractId() throws SQLException {
checkForDao();
@SuppressWarnings("unchecked")
T t = (T) this;
return dao.extractId(t);
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* A call through to the {@link Dao#extractId(Object)}.
*/
public ID extractId() throws SQLException {
checkForDao();
@SuppressWarnings("unchecked")
T t = (T) this;
return dao.extractId(t);
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#extractId(Object)
*/
@Override
public ID extractId(T data) {
try {
return dao.extractId(data);
} catch (SQLException e) {
logMessage(e, "extractId threw exception on: " + data);
throw new RuntimeException(e);
}
}
代码示例来源:origin: j256/ormlite-core
/**
* Add a clause where the ID is from an existing object.
*/
public <OD> Where<T, ID> idEq(Dao<OD, ?> dataDao, OD data) throws SQLException {
if (idColumnName == null) {
throw new SQLException("Object has no id column specified");
}
addClause(new SimpleComparison(idColumnName, idFieldType, dataDao.extractId(data),
SimpleComparison.EQUAL_TO_OPERATION));
return this;
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* Add a clause where the ID is from an existing object.
*/
public <OD> Where<T, ID> idEq(Dao<OD, ?> dataDao, OD data) throws SQLException {
if (idColumnName == null) {
throw new SQLException("Object has no id column specified");
}
addClause(new SimpleComparison(idColumnName, idFieldType, dataDao.extractId(data),
SimpleComparison.EQUAL_TO_OPERATION));
return this;
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = RuntimeException.class)
public void testExtractIdThrow() throws Exception {
@SuppressWarnings("unchecked")
Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
expect(dao.extractId(null)).andThrow(new SQLException("Testing catch"));
replay(dao);
rtDao.extractId(null);
verify(dao);
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testExtractIdBadClass() throws Exception {
Dao<NoId, Void> dao = createDao(NoId.class, true);
NoId foo = new NoId();
String stuff = "stuff1";
foo.stuff = stuff;
dao.extractId(foo);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testExtractId() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo = new Foo();
assertEquals((Integer) foo.id, dao.extractId(foo));
}
内容来源于网络,如有侵权,请联系作者删除!