本文整理汇总了Java中org.apache.metamodel.schema.Table.getPrimaryKeys方法的典型用法代码示例。如果您正苦于以下问题:Java Table.getPrimaryKeys方法的具体用法?Java Table.getPrimaryKeys怎么用?Java Table.getPrimaryKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.metamodel.schema.Table
的用法示例。
在下文中一共展示了Table.getPrimaryKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeveloperTable
import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
public void testDeveloperTable() throws Exception {
Schema schema = dc.getDefaultSchema();
assertEquals("developers.mdb", schema.getName());
assertEquals("[developer, product]", schema.getTableNames().toString());
Table table = schema.getTableByName("developer");
assertEquals("[id, name, email, male, developer_since]", table.getColumnNames().toString());
List<Column> primaryKeys = table.getPrimaryKeys();
assertEquals("[Column[name=id,columnNumber=0,type=INTEGER,nullable=null,nativeType=LONG,columnSize=4]]", primaryKeys.toString());
Column nameCol = table.getColumnByName("name");
assertEquals(
"Column[name=name,columnNumber=1,type=VARCHAR,nullable=null,nativeType=TEXT,columnSize=100]",
nameCol.toString());
Column maleCol = table.getColumnByName("male");
assertEquals(
"Column[name=male,columnNumber=3,type=BOOLEAN,nullable=null,nativeType=BOOLEAN,columnSize=1]",
maleCol.toString());
Column developerSinceCol = table.getColumnByName("developer_since");
assertEquals(
"Column[name=developer_since,columnNumber=4,type=TIMESTAMP,nullable=null,nativeType=SHORT_DATE_TIME,columnSize=8]",
developerSinceCol.toString());
DataSet ds = dc.executeQuery(new Query().select(nameCol, maleCol, developerSinceCol).from(table));
while (ds.next()) {
Row row = ds.getRow();
assertEquals(3, row.getValues().length);
Object value = row.getValue(0);
assertEquals(String.class, value.getClass());
value = row.getValue(1);
assertEquals(Boolean.class, value.getClass());
value = row.getValue(2);
assertTrue(value instanceof Date);
}
}