本文整理了Java中org.hibernate.mapping.Table.getColumnSpan()
方法的一些代码示例,展示了Table.getColumnSpan()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getColumnSpan()
方法的具体详情如下:
包路径:org.hibernate.mapping.Table
类名称:Table
方法名:getColumnSpan
暂无
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testRevEntityTableCreation() {
for ( Table table : metadata().collectTableMappings() ) {
if ( "REVCHANGES".equals( table.getName() ) ) {
assert table.getColumnSpan() == 2;
assert table.getColumn( new Column( "REV" ) ) != null;
assert table.getColumn( new Column( "ENTITYNAME" ) ) != null;
return;
}
}
assert false;
}
代码示例来源:origin: hibernate/hibernate-orm
private void assertSameTableUsed(Metadata metadata) {
Collection inputs1Mapping = metadata.getCollectionBinding( Ptx.class.getName() + ".inputs1" );
assertEquals( "ptx_input", inputs1Mapping.getCollectionTable().getName() );
Collection inputs2Mapping = metadata.getCollectionBinding( Ptx.class.getName() + ".inputs2" );
assertEquals( "ptx_input", inputs2Mapping.getCollectionTable().getName() );
assertSame( inputs1Mapping.getCollectionTable(), inputs2Mapping.getCollectionTable() );
// NOTE : here so that tester can more easily see the produced table. It is only dumped to stdout
new SchemaExport().create( EnumSet.of( TargetType.STDOUT ), metadata );
for ( int i = 0; i < inputs1Mapping.getCollectionTable().getColumnSpan(); i++ ) {
final Column column = inputs1Mapping.getCollectionTable().getColumn( i );
// this, coupled with JPA saying the 2 collections implicitly map to the same table,
// is the crux of the problem: all columns are null, so we effectively can never
// insert rows into it.
assertFalse( column.isNullable() );
}
}
代码示例来源:origin: hibernate/hibernate-orm
protected void checkDefaultJoinTableAndAllColumnNames(
Metadata metadata,
Class<?> ownerEntityClass,
String ownerCollectionPropertyName,
String expectedCollectionTableName,
String ownerForeignKeyNameExpected,
String[] columnNames) {
final org.hibernate.mapping.Collection collection = metadata.getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName );
final org.hibernate.mapping.Table table = collection.getCollectionTable();
assertEquals( expectedCollectionTableName, table.getName() );
// The default owner and inverse join columns can only be computed if they have PK with 1 column.
assertEquals( 1, collection.getOwner().getKey().getColumnSpan() );
assertEquals(
ownerForeignKeyNameExpected,
collection.getKey().getColumnIterator().next().getText()
);
int columnNumber = table.getColumnSpan();
for ( int i = 0; i < columnNumber; i++ ) {
assertEquals( columnNames[i], table.getColumn( i + 1 ).getName());
}
}
代码示例来源:origin: hibernate/hibernate-tools
if ( pk==null || pk.getColumns().size() != table.getColumnSpan() )
return false;
代码示例来源:origin: hibernate/hibernate-tools
@Test
public void testBasic() throws SQLException {
Metadata metadata = MetadataDescriptorFactory
.createJdbcDescriptor(null, null, true)
.createMetadata();
JUnitUtil.assertIteratorContainsExactly(
"There should be " + TABLECOUNT + " tables!",
metadata.collectTableMappings().iterator(),
TABLECOUNT);
Table tab = (Table) metadata.collectTableMappings().iterator().next();
Assert.assertEquals(tab.getColumnSpan(), COLCOUNT+1);
}
代码示例来源:origin: org.hibernate/hibernate-tools
if ( pk==null || pk.getColumns().size() != table.getColumnSpan() )
return false;
代码示例来源:origin: hibernate/hibernate-tools
@Test
public void testBasic() throws SQLException {
JUnitUtil.assertIteratorContainsExactly(
"There should be 2 tables!",
metadata.collectTableMappings().iterator(),
2);
Table table = HibernateUtil.getTable(metadata, JdbcUtil.toIdentifier(this, "B_TAB" ) );
Table table2 = HibernateUtil.getTable(metadata, JdbcUtil.toIdentifier(this, "B2TAB" ) );
Assert.assertNotNull(table);
Assert.assertNotNull(table2);
Assert.assertEquals(table.getColumnSpan(), 2);
Assert.assertEquals(table2.getColumnSpan(), 2);
}
代码示例来源:origin: hibernate/hibernate-tools
@Test
public void testForQuotes() {
Table table = HibernateUtil.getTable(metadata, "us-ers");
Assert.assertNotNull(table);
Assert.assertTrue(table.isQuoted());
Assert.assertEquals(2, table.getColumnSpan());
PersistentClass classMapping = metadata.getEntityBinding("Worklogs");
Assert.assertNotNull(classMapping);
Property property = classMapping.getProperty("usErs");
Assert.assertNotNull(property);
}
代码示例来源:origin: org.hibernate/hibernate-tools
table.setSchema(null);
if(table.getColumnSpan()==0) {
log.warn("Cannot create persistent class for " + table + " as no columns were found.");
continue;
代码示例来源:origin: hibernate/hibernate-tools
table.setSchema(null);
if(table.getColumnSpan()==0) {
log.warn("Cannot create persistent class for " + table + " as no columns were found.");
continue;
代码示例来源:origin: hibernate/hibernate-tools
@Test
public void testBasic() throws SQLException {
JUnitUtil.assertIteratorContainsExactly(
"There should be three tables!",
metadata.getEntityBindings().iterator(),
3);
Table table = HibernateUtil.getTable(
metadata,
JdbcUtil.toIdentifier(this, "BASIC"));
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "BASIC"),
JdbcUtil.toIdentifier(this, table.getName()));
Assert.assertEquals(2, table.getColumnSpan());
Column basicColumn = table.getColumn(0);
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "A"),
JdbcUtil.toIdentifier(this, basicColumn.getName()));
PrimaryKey key = table.getPrimaryKey();
Assert.assertNotNull("There should be a primary key!", key);
Assert.assertEquals(key.getColumnSpan(), 1);
Column column = key.getColumn(0);
Assert.assertTrue(column.isUnique());
Assert.assertSame(basicColumn, column);
}
代码示例来源:origin: hibernate/hibernate-tools
@Test
public void testBasic() throws SQLException {
JUnitUtil.assertIteratorContainsExactly(
"There should be three tables!",
metadata.getEntityBindings().iterator(),
3);
Table table = HibernateUtil.getTable(
metadata,
JdbcUtil.toIdentifier(this, "BASIC" ) );
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "BASIC"),
JdbcUtil.toIdentifier(this, table.getName()) );
Assert.assertEquals( 2, table.getColumnSpan() );
Column basicColumn = table.getColumn( 0 );
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "A"),
JdbcUtil.toIdentifier(this, basicColumn.getName() ));
// TODO: we cannot call getSqlType(dialect,cfg) without a
// MappingassertEquals("INTEGER", basicColumn.getSqlType() ); // at
// least on hsqldb
// assertEquals(22, basicColumn.getLength() ); // at least on oracle
PrimaryKey key = table.getPrimaryKey();
Assert.assertNotNull( "There should be a primary key!", key );
Assert.assertEquals( key.getColumnSpan(), 1 );
Column column = key.getColumn( 0 );
Assert.assertTrue( column.isUnique() );
Assert.assertSame( basicColumn, column );
}
代码示例来源:origin: hibernate/hibernate-tools
@Test
public void testBasic() {
JUnitUtil.assertIteratorContainsExactly(
"There should be three tables!",
metadata.getEntityBindings().iterator(),
3);
Table table = HibernateUtil.getTable(
metadata,
JdbcUtil.toIdentifier(this, "BASIC" ) );
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "BASIC"),
JdbcUtil.toIdentifier(this, table.getName()));
Assert.assertEquals( 2, table.getColumnSpan() );
Column basicColumn = table.getColumn( 0 );
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "A"),
JdbcUtil.toIdentifier(this, basicColumn.getName()));
// TODO: we cannot call getSqlType(dialect,cfg) without a
// MappingassertEquals("INTEGER", basicColumn.getSqlType() ); // at
// least on hsqldb
// assertEquals(22, basicColumn.getLength() ); // at least on oracle
PrimaryKey key = table.getPrimaryKey();
Assert.assertNotNull( "There should be a primary key!", key );
Assert.assertEquals( key.getColumnSpan(), 1 );
Column column = key.getColumn( 0 );
Assert.assertTrue( column.isUnique() );
Assert.assertSame( basicColumn, column );
}
内容来源于网络,如有侵权,请联系作者删除!