本文整理了Java中org.hibernate.mapping.Column.<init>()
方法的一些代码示例,展示了Column.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Column.<init>()
方法的具体详情如下:
包路径:org.hibernate.mapping.Column
类名称:Column
方法名:<init>
暂无
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected void augmentIdTableDefinition(Table idTable) {
Column sessionIdColumn = new Column( Helper.SESSION_ID_COLUMN_NAME );
sessionIdColumn.setSqlType( "CHAR(36)" );
sessionIdColumn.setComment( "Used to hold the Hibernate Session identifier" );
idTable.addColumn( sessionIdColumn );
}
代码示例来源:origin: hibernate/hibernate-orm
private void checkTableColumns(Set<String> expectedColumns, Set<String> unexpectedColumns, Table table) {
for ( String columnName : expectedColumns ) {
// Check whether expected column exists.
Assert.assertNotNull( table.getColumn( new Column( columnName ) ) );
}
for ( String columnName : unexpectedColumns ) {
// Check whether unexpected column does not exist.
Assert.assertNull( table.getColumn( new Column( columnName ) ) );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testAuditedProperty() {
Assert.assertNotNull( classAuditedTable.getColumn( new Column( "number1" ) ) );
Assert.assertNotNull( classAuditedTable.getColumn( new Column( "str1" ) ) );
Assert.assertNotNull( classAuditedTable.getColumn( new Column( "str2" ) ) );
Assert.assertNotNull( classNotAuditedTable.getColumn( new Column( "str2" ) ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testAuditedProperty() {
Assert.assertNotNull( propertyTable.getColumn( new Column( "number1" ) ) );
Assert.assertNotNull( transitiveTable.getColumn( new Column( "number2" ) ) );
Assert.assertNotNull( auditedTable.getColumn( new Column( "str1" ) ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testNotAuditedProperty() {
Assert.assertNull( classNotAuditedTable.getColumn( new Column( "number1" ) ) );
Assert.assertNull( classNotAuditedTable.getColumn( new Column( "str1" ) ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testTransitiveAuditedProperty() {
Assert.assertNotNull( transitiveTable.getColumn( new Column( "number1" ) ) );
Assert.assertNotNull( transitiveTable.getColumn( new Column( "str1" ) ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testAuditedProperty() {
Assert.assertNotNull( mixedTable.getColumn( new Column( "number1" ) ) );
Assert.assertNotNull( mixedTable.getColumn( new Column( "str2" ) ) );
}
代码示例来源: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
@Test
public void testNotAuditedProperty() {
Assert.assertNull( propertyTable.getColumn( new Column( "str1" ) ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testNotAuditedProperty() {
Assert.assertNull( mixedTable.getColumn( new Column( "str1" ) ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testAuditTableColumns() {
Assert.assertNotNull( uniquePropsAudit.getTable().getColumn( new Column( "DATA1" ) ) );
Assert.assertNotNull( uniquePropsAudit.getTable().getColumn( new Column( "DATA2" ) ) );
Assert.assertNotNull( uniquePropsNotAuditedAudit.getTable().getColumn( new Column( "DATA1" ) ) );
Assert.assertNull( uniquePropsNotAuditedAudit.getTable().getColumn( new Column( "DATA2" ) ) );
}
代码示例来源:origin: hibernate/hibernate-orm
private void addConstraintToColumn(final String columnName ) {
Column column = table.getColumn(
new Column(
buildingContext.getMetadataCollector().getPhysicalColumnName( table, columnName )
)
);
if ( column == null ) {
throw new AnnotationException(
"@Index references a unknown column: " + columnName
);
}
if ( unique ) {
table.getOrCreateUniqueKey( indexName ).addColumn( column );
}
else {
table.getOrCreateIndex( indexName ).addColumn( column );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testDefaultValue() throws Exception {
Join join = (Join) metadata().getEntityBinding( Life.class.getName() ).getJoinClosureIterator().next();
assertEquals( "ExtendedLife", join.getTable().getName() );
org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
owner.setName( "LIFE_ID" );
assertTrue( join.getTable().getPrimaryKey().containsColumn( owner ) );
Session s = openSession();
Transaction tx = s.beginTransaction();
Life life = new Life();
life.duration = 15;
life.fullDescription = "Long long description";
s.persist( life );
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
Query q = s.createQuery( "from " + Life.class.getName() );
life = (Life) q.uniqueResult();
assertEquals( "Long long description", life.fullDescription );
tx.commit();
s.close();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testCreatedAuditTable() {
Set<String> expectedColumns = TestTools.makeSet( "child", "grandparent", "id" );
Set<String> unexpectedColumns = TestTools.makeSet( "parent", "relation_id", "notAudited" );
Table table = metadata().getEntityBinding(
"org.hibernate.envers.test.integration.superclass.auditparents.ChildSingleParentEntity_AUD"
).getTable();
for ( String columnName : expectedColumns ) {
// Check whether expected column exists.
Assert.assertNotNull( table.getColumn( new Column( columnName ) ) );
}
for ( String columnName : unexpectedColumns ) {
// Check whether unexpected column does not exist.
Assert.assertNull( table.getColumn( new Column( columnName ) ) );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testCreatedAuditTable() {
Set<String> expectedColumns = TestTools.makeSet( "child", "parent", "relation_id", "grandparent", "id" );
Set<String> unexpectedColumns = TestTools.makeSet( "notAudited" );
Table table = metadata().getEntityBinding(
"org.hibernate.envers.test.integration.superclass.auditparents.ChildMultipleParentsEntity_AUD"
).getTable();
for ( String columnName : expectedColumns ) {
// Check whether expected column exists.
Assert.assertNotNull( table.getColumn( new Column( columnName ) ) );
}
for ( String columnName : unexpectedColumns ) {
// Check whether unexpected column does not exist.
Assert.assertNull( table.getColumn( new Column( columnName ) ) );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testCompositePK() throws Exception {
Join join = (Join) metadata().getEntityBinding( Dog.class.getName() ).getJoinClosureIterator().next();
assertEquals( "DogThoroughbred", join.getTable().getName() );
org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
owner.setName( "OWNER_NAME" );
assertTrue( join.getTable().getPrimaryKey().containsColumn( owner ) );
Session s = openSession();
Transaction tx = s.beginTransaction();
Dog dog = new Dog();
DogPk id = new DogPk();
id.name = "Thalie";
id.ownerName = "Martine";
dog.id = id;
dog.weight = 30;
dog.thoroughbredName = "Colley";
s.persist( dog );
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
Query q = s.createQuery( "from Dog" );
dog = (Dog) q.uniqueResult();
assertEquals( "Colley", dog.thoroughbredName );
tx.commit();
s.close();
}
代码示例来源:origin: hibernate/hibernate-orm
foreignKey.addColumn( new Column( "id" ) );
foreignKey.setReferencedTable( new Table( "table2" ) );
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testCreatedAuditTable() {
Set<String> expectedColumns = TestTools.makeSet(
"baby",
"child",
"parent",
"relation_id",
"grandparent",
"id"
);
Set<String> unexpectedColumns = TestTools.makeSet( "notAudited" );
Table table = metadata().getEntityBinding(
"org.hibernate.envers.test.integration.superclass.auditparents.BabyCompleteEntity_AUD"
).getTable();
for ( String columnName : expectedColumns ) {
// Check whether expected column exists.
Assert.assertNotNull( table.getColumn( new Column( columnName ) ) );
}
for ( String columnName : unexpectedColumns ) {
// Check whether unexpected column does not exist.
Assert.assertNull( table.getColumn( new Column( columnName ) ) );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testColumnScalePrecision() {
Column testColumn = new Column( "wholeNumber" );
Column scalePrecisionAuditColumn = auditTable.getColumn( testColumn );
Column scalePrecisionColumn = originalTable.getColumn( testColumn );
Assert.assertNotNull( scalePrecisionAuditColumn );
Assert.assertEquals( scalePrecisionColumn.getPrecision(), scalePrecisionAuditColumn.getPrecision() );
Assert.assertEquals( scalePrecisionColumn.getScale(), scalePrecisionAuditColumn.getScale() );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Shallow copy, the value is not copied
*/
@Override
public Column clone() {
Column copy = new Column();
copy.setLength( length );
copy.setScale( scale );
copy.setValue( value );
copy.setTypeIndex( typeIndex );
copy.setName( getQuotedName() );
copy.setNullable( nullable );
copy.setPrecision( precision );
copy.setUnique( unique );
copy.setSqlType( sqlType );
copy.setSqlTypeCode( sqlTypeCode );
copy.uniqueInteger = uniqueInteger; //usually useless
copy.setCheckConstraint( checkConstraint );
copy.setComment( comment );
copy.setDefaultValue( defaultValue );
copy.setCustomRead( customRead );
copy.setCustomWrite( customWrite );
return copy;
}
内容来源于网络,如有侵权,请联系作者删除!