public int getColumnSpan() { return associatedClass.getKey().getColumnSpan(); }
List<String> idColumnNames = new ArrayList<>(); org.hibernate.mapping.Column currentColumn; if ( identifier.getColumnSpan() != joinColumns.length ) { mapToPK = false;
void createPrimaryKey() { if ( !isOneToMany() ) { PrimaryKey pk = new PrimaryKey( getCollectionTable() ); pk.addColumns( getKey().getColumnIterator() ); Iterator iter = getElement().getColumnIterator(); while ( iter.hasNext() ) { Object selectable = iter.next(); if ( selectable instanceof Column ) { Column col = (Column) selectable; if ( !col.isNullable() ) { pk.addColumn( col ); } else { return; } } } if ( pk.getColumnSpan() == getKey().getColumnSpan() ) { //for backward compatibility, allow a set with no not-null //element columns, using all columns in the row locater SQL //TODO: create an implicit not null constraint on all cols? } else { getCollectionTable().setPrimaryKey( pk ); } } else { //create an index on the key columns?? } }
identifierColumnSpan = persistentClass.getIdentifier().getColumnSpan(); rootTableKeyColumnNames = new String[identifierColumnSpan]; rootTableKeyColumnReaders = new String[identifierColumnSpan];
protected void validateCustomerOrders(Metadata metadata) { final Collection collectionBinding = metadata.getCollectionBinding( Customer.class.getName() + ".orders" ); assertNotNull( collectionBinding ); validateCustomerOrdersTableName( collectionBinding.getCollectionTable().getQuotedName() ); assertEquals( 1, collectionBinding.getKey().getColumnSpan() ); validateCustomerOrdersKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() ); assertEquals( 1, collectionBinding.getElement().getColumnSpan() ); validateCustomerOrdersElementColumn( (Column) collectionBinding.getElement().getColumnIterator().next() ); }
protected void validateCustomerIndustries(Metadata metadata) { final Collection collectionBinding = metadata.getCollectionBinding( Customer.class.getName() + ".industries" ); assertNotNull( collectionBinding ); validateCustomerIndustriesTableName( collectionBinding.getCollectionTable().getQuotedName() ); assertEquals( 1, collectionBinding.getKey().getColumnSpan() ); validateCustomerIndustriesKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() ); assertEquals( 1, collectionBinding.getElement().getColumnSpan() ); validateCustomerIndustriesElementColumn( (Column) collectionBinding.getElement().getColumnIterator().next() ); }
protected void validateCustomerRegisteredTrademarks(Metadata metadata) { final Collection collectionBinding = metadata.getCollectionBinding( Customer.class.getName() + ".registeredTrademarks" ); assertNotNull( collectionBinding ); validateCustomerRegisteredTrademarksTableName( collectionBinding.getCollectionTable().getQuotedName() ); assertEquals( 1, collectionBinding.getKey().getColumnSpan() ); validateCustomerRegisteredTrademarksKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() ); assertEquals( 1, collectionBinding.getElement().getColumnSpan() ); validateCustomerRegisteredTrademarksElementColumn( (Column) collectionBinding.getElement() .getColumnIterator() .next() ); }
protected void validateCustomerAddresses(Metadata metadata) { final Collection collectionBinding = metadata.getCollectionBinding( Customer.class.getName() + ".addresses" ); assertNotNull( collectionBinding ); validateCustomerAddressesTableName( collectionBinding.getCollectionTable().getQuotedName() ); assertEquals( 1, collectionBinding.getKey().getColumnSpan() ); validateCustomerAddressesKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() ); assertEquals( 3, collectionBinding.getElement().getColumnSpan() ); validateCustomerAddressesElementComponent( assertTyping( Component.class, collectionBinding.getElement() ) ); }
keyColumnNames[j] = new String[join.getKey().getColumnSpan()]; int i = 0; while ( iter.hasNext() ) { String[] keyCols = new String[join.getKey().getColumnSpan()]; int i = 0; while ( iter.hasNext() ) {
int joinIdColumnSpan = key.getColumnSpan();
protected void checkDefaultJoinColumnName( Class<?> ownerEntityClass, String ownerCollectionPropertyName, String ownerForeignKeyNameExpected) { final org.hibernate.mapping.Collection ownerCollection = metadata().getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName ); // The default owner join column can only be computed if it has a PK with 1 column. assertEquals ( 1, ownerCollection.getOwner().getKey().getColumnSpan() ); assertEquals( ownerForeignKeyNameExpected, ownerCollection.getKey().getColumnIterator().next().getText() ); boolean hasOwnerFK = false; for ( Iterator it=ownerCollection.getCollectionTable().getForeignKeyIterator(); it.hasNext(); ) { final ForeignKey fk = (ForeignKey) it.next(); assertSame( ownerCollection.getCollectionTable(), fk.getTable() ); if ( fk.getColumnSpan() > 1 ) { continue; } if ( fk.getColumn( 0 ).getText().equals( ownerForeignKeyNameExpected ) ) { assertSame( ownerCollection.getOwner().getTable(), fk.getReferencedTable() ); hasOwnerFK = true; } } assertTrue( hasOwnerFK ); }
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()); } }
protected void validateZipCode(Metadata metadata) { final PersistentClass zipCodeBinding = metadata.getEntityBinding( ZipCode.class.getName() ); assertNotNull( zipCodeBinding ); validateZipCodePrimaryTableName( zipCodeBinding.getTable().getQuotedName() ); assertEquals( 1, zipCodeBinding.getIdentifier().getColumnSpan() ); validateZipCodePrimaryKeyColumn( (Column) zipCodeBinding.getIdentifier().getColumnIterator().next() ); final Property codeBinding = zipCodeBinding.getProperty( "code" ); assertNotNull( codeBinding ); assertEquals( 1, codeBinding.getColumnSpan() ); validateZipCodeCodeColumn( (Column) codeBinding.getColumnIterator().next() ); final Property cityBinding = zipCodeBinding.getProperty( "city" ); assertNotNull( cityBinding ); assertEquals( 1, cityBinding.getColumnSpan() ); validateZipCodeCityColumn( (Column) cityBinding.getColumnIterator().next() ); final Property stateBinding = zipCodeBinding.getProperty( "state" ); assertNotNull( stateBinding ); assertEquals( 1, stateBinding.getColumnSpan() ); validateZipCodeStateColumn( (Column) stateBinding.getColumnIterator().next() ); }
if ( Ejb3JoinColumn.NO_REFERENCE == fkEnum ) { if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) { throw new AnnotationException( "A Foreign key refering " + referencedEntity.getEntityName() + " from " + associatedClass.getEntityName() + " has the wrong number of column. should be " + referencedEntity.getIdentifier() .getColumnSpan() );
protected void validateOrder(Metadata metadata) { final PersistentClass orderBinding = metadata.getEntityBinding( Order.class.getName() ); assertNotNull( orderBinding ); validateOrderPrimaryTableName( orderBinding.getTable().getQuotedName() ); assertEquals( 1, orderBinding.getIdentifier().getColumnSpan() ); validateOrderPrimaryKeyColumn( (Column) orderBinding.getIdentifier().getColumnIterator().next() ); final Property referenceCodeBinding = orderBinding.getProperty( "referenceCode" ); assertNotNull( referenceCodeBinding ); assertEquals( 1, referenceCodeBinding.getColumnSpan() ); validateOrderReferenceCodeColumn( (Column) referenceCodeBinding.getColumnIterator().next() ); final Property placedBinding = orderBinding.getProperty( "placed" ); assertNotNull( placedBinding ); assertEquals( 1, placedBinding.getColumnSpan() ); validateOrderPlacedColumn( (Column) placedBinding.getColumnIterator().next() ); final Property fulfilledBinding = orderBinding.getProperty( "fulfilled" ); assertNotNull( fulfilledBinding ); assertEquals( 1, fulfilledBinding.getColumnSpan() ); validateOrderFulfilledColumn( (Column) fulfilledBinding.getColumnIterator().next() ); final Property customerBinding = orderBinding.getProperty( "customer" ); assertNotNull( customerBinding ); assertEquals( 1, customerBinding.getColumnSpan() ); validateOrderCustomerColumn( (Column) customerBinding.getColumnIterator().next() ); }
protected void validateCustomer(Metadata metadata) { final PersistentClass customerBinding = metadata.getEntityBinding( Customer.class.getName() ); assertNotNull( customerBinding ); validateCustomerPrimaryTableName( customerBinding.getTable().getQuotedName() ); assertEquals( 1, customerBinding.getIdentifier().getColumnSpan() ); validateCustomerPrimaryKeyColumn( (Column) customerBinding.getIdentifier().getColumnIterator().next() ); assertNotNull( customerBinding.getVersion() ); assertEquals( 1, customerBinding.getVersion().getColumnSpan() ); validateCustomerVersionColumn( (Column) customerBinding.getVersion().getColumnIterator().next() ); final Property nameBinding = customerBinding.getProperty( "name" ); assertNotNull( nameBinding ); assertEquals( 1, nameBinding.getColumnSpan() ); validateCustomerNameColumn( (Column) nameBinding.getColumnIterator().next() ); final Property hqAddressBinding = customerBinding.getProperty( "hqAddress" ); assertNotNull( hqAddressBinding ); assertEquals( 3, hqAddressBinding.getColumnSpan() ); validateCustomerHqAddressComponent( assertTyping( Component.class, hqAddressBinding.getValue() ) ); }
); assertEquals ( 1, ownerCollection.getOwner().getKey().getColumnSpan() ); assertEquals( ownerForeignKeyNameExpected, ownerCollection.getKey().getColumnIterator().next().getText() ); final PersistentClass associatedPersistentClass = metadata().getEntityBinding( associatedEntityType.getAssociatedEntityName() ); assertEquals( 1, associatedPersistentClass.getKey().getColumnSpan() ); if ( inverseCollectionPropertyName != null ) { final org.hibernate.mapping.Collection inverseCollection = metadata().getCollectionBinding(
int keySpan = collectionBinding.getKey().getColumnSpan(); keyColumnNames = new String[keySpan]; keyColumnAliases = new String[keySpan];
List<String> idColumnNames = new ArrayList<String>(); org.hibernate.mapping.Column currentColumn; if ( identifier.getColumnSpan() != joinColumns.length ) { mapToPK = false;
if ( Ejb3JoinColumn.NO_REFERENCE == fkEnum ) { if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) { throw new AnnotationException( "A Foreign key refering " + referencedEntity.getEntityName() + " from " + associatedClass.getEntityName() + " has the wrong number of column. should be " + referencedEntity.getIdentifier() .getColumnSpan() );