public java.util.List getConstraintColumns() { ArrayList list = new ArrayList(); Iterator iter = identifier.getColumnIterator(); while ( iter.hasNext() ) { list.add( iter.next() ); } return list; } /**
public Iterator<Selectable> getColumnIterator() { return associatedClass.getKey().getColumnIterator(); }
public void doSecondPass(Map persistentClasses) throws MappingException { PersistentClass referencedEntity = (PersistentClass) persistentClasses.get( referencedEntityName ); if ( referencedEntity == null ) { throw new AnnotationException( "Unknown entity name: " + referencedEntityName ); } TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit( referencedEntity, referencedEntity.getKey().getColumnIterator(), columns, value); } }
protected void checkColumnDuplication() { HashSet cols = new HashSet(); if ( getIdentifierMapper() == null ) { //an identifier mapper => getKey will be included in the getNonDuplicatedPropertyIterator() //and checked later, so it needs to be excluded checkColumnDuplication( cols, getKey().getColumnIterator() ); } checkColumnDuplication( cols, getDiscriminatorColumnIterator() ); checkPropertyColumnDuplication( cols, getNonDuplicatedPropertyIterator() ); Iterator iter = getJoinIterator(); while ( iter.hasNext() ) { cols.clear(); Join join = (Join) iter.next(); checkColumnDuplication( cols, join.getKey().getColumnIterator() ); checkPropertyColumnDuplication( cols, join.getPropertyIterator() ); } }
@SuppressWarnings({"unchecked"}) private String searchMappedBy(PersistentClass referencedClass, Collection collectionValue) { final Iterator<Property> assocClassProps = referencedClass.getPropertyIterator(); while ( assocClassProps.hasNext() ) { final Property property = assocClassProps.next(); if ( Tools.iteratorsContentEqual( property.getValue().getColumnIterator(), collectionValue.getKey().getColumnIterator() ) ) { return property.getName(); } } // HHH-7625 // Support ToOne relations with mappedBy that point to an @IdClass key property. return searchMappedByKey( referencedClass, collectionValue ); }
public void createPrimaryKey() { //Primary key constraint PrimaryKey pk = new PrimaryKey( table ); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey(pk); pk.addColumns( getKey().getColumnIterator() ); }
void createPrimaryKey() { if ( !isOneToMany() ) { PrimaryKey pk = new PrimaryKey( getCollectionTable() ); pk.addColumns( getIdentifier().getColumnIterator() ); getCollectionTable().setPrimaryKey(pk); } // create an index on the key columns?? }
@Test public void testChildRevColumnType() { // We need the second column Iterator childEntityKeyColumnsIterator = metadata() .getEntityBinding("org.hibernate.envers.test.integration.inheritance.joined.ChildEntity_AUD" ) .getKey() .getColumnIterator(); childEntityKeyColumnsIterator.next(); Column second = (Column) childEntityKeyColumnsIterator.next(); assertEquals( second.getSqlType(), "int" ); } }
public void createPrimaryKey() { //Primary key constraint final Table table = getTable(); PrimaryKey pk = new PrimaryKey( table ); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey( pk ); pk.addColumns( getKey().getColumnIterator() ); }
@Test public void testChildIdColumnName() { Assert.assertEquals( "other_id", ((Column) metadata().getEntityBinding( "org.hibernate.envers.test.integration.inheritance.joined.primarykeyjoin.ChildPrimaryKeyJoinEntity_AUD" ).getKey().getColumnIterator().next()).getName() ); } }
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 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 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() ) ); }
@Override public void doTestWork(StandardServiceRegistry ssr) { MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( E1.class ) .buildMetadata(); metadata.validate(); PersistentClass entityBinding = metadata.getEntityBinding( E1.class.getName() ); org.hibernate.mapping.Column idColumn = extractColumn( entityBinding.getIdentifier().getColumnIterator() ); assertTrue( isQuoted( idColumn.getSqlType(), ssr ) ); org.hibernate.mapping.Column otherColumn = extractColumn( entityBinding.getProperty( "other" ).getColumnIterator() ); assertTrue( isQuoted( otherColumn.getSqlType(), ssr ) ); } }
@Override public void doTestWork(StandardServiceRegistry ssr) { MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( E2.class ) .buildMetadata(); metadata.validate(); PersistentClass entityBinding = metadata.getEntityBinding( E2.class.getName() ); org.hibernate.mapping.Column idColumn = extractColumn( entityBinding.getIdentifier().getColumnIterator() ); assertTrue( !isQuoted( idColumn.getSqlType(), ssr ) ); org.hibernate.mapping.Column otherColumn = extractColumn( entityBinding.getProperty( "other" ).getColumnIterator() ); assertTrue( !isQuoted( otherColumn.getSqlType(), ssr ) ); } }
@Override public void doTestWork(StandardServiceRegistry ssr) { MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( E1.class ) .buildMetadata(); metadata.validate(); PersistentClass entityBinding = metadata.getEntityBinding( E1.class.getName() ); org.hibernate.mapping.Column idColumn = extractColumn( entityBinding.getIdentifier().getColumnIterator() ); assertTrue( isQuoted( idColumn.getSqlType(), ssr ) ); org.hibernate.mapping.Column otherColumn = extractColumn( entityBinding.getProperty( "other" ).getColumnIterator() ); assertTrue( isQuoted( otherColumn.getSqlType(), ssr ) ); } }
@Override public void doTestWork(StandardServiceRegistry ssr) { MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( E2.class ) .buildMetadata(); metadata.validate(); PersistentClass entityBinding = metadata.getEntityBinding( E2.class.getName() ); org.hibernate.mapping.Column idColumn = extractColumn( entityBinding.getIdentifier().getColumnIterator() ); assertTrue( isQuoted( idColumn.getSqlType(), ssr ) ); org.hibernate.mapping.Column otherColumn = extractColumn( entityBinding.getProperty( "other" ).getColumnIterator() ); assertTrue( isQuoted( otherColumn.getSqlType(), ssr ) ); } }
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() ); }
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() ) ); }