public int getColumnSpan() { return value.getColumnSpan(); }
private void makeOneToManyMapKeyColumnNullableIfNotInProperty( final XProperty property) { final org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) this.collection; if ( map.isOneToMany() && property.isAnnotationPresent( MapKeyColumn.class ) ) { final Value indexValue = map.getIndex(); if ( indexValue.getColumnSpan() != 1 ) { throw new AssertionFailure( "Map key mapped by @MapKeyColumn does not have 1 column" ); } final Selectable selectable = indexValue.getColumnIterator().next(); if ( selectable.isFormula() ) { throw new AssertionFailure( "Map key mapped by @MapKeyColumn is a Formula" ); } Column column = (Column) map.getIndex().getColumnIterator().next(); if ( !column.isNullable() ) { final PersistentClass persistentClass = ( ( OneToMany ) map.getElement() ).getAssociatedClass(); // check if the index column has been mapped by the associated entity to a property; // @MapKeyColumn only maps a column to the primary table for the one-to-many, so we only // need to check "un-joined" properties. if ( !propertyIteratorContainsColumn( persistentClass.getUnjoinedPropertyIterator(), column ) ) { // The index column is not mapped to an associated entity property so we can // safely make the index column nullable. column.setNullable( true ); } } } }
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() ) ); }
Component investmentMetadata = (Component) investmentsValue.getElement(); Value descriptionValue = investmentMetadata.getProperty( "description" ).getValue(); assertEquals( 1, descriptionValue.getColumnSpan() ); Column selectable = (Column) descriptionValue.getColumnIterator().next(); assertEquals( 500, selectable.getLength() );
@Test @FailureExpected( jiraKey = "HHH-9089" ) public void testEnumTypeInterpretation() { StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); try { final Metadata metadata = new MetadataSources( ssr ) .addAnnotatedClass( Customer.class ) .buildMetadata(); PersistentClass classMetadata = metadata.getEntityBinding( Customer.class.getName() ); Property investmentsProperty = classMetadata.getProperty( "investments" ); Collection investmentsValue = (Collection) investmentsProperty.getValue(); Component investmentMetadata = (Component) investmentsValue.getElement(); Value descriptionValue = investmentMetadata.getProperty( "description" ).getValue(); assertEquals( 1, descriptionValue.getColumnSpan() ); Column selectable = (Column) descriptionValue.getColumnIterator().next(); assertEquals( 500, selectable.getLength() ); Component amountMetadata = (Component) investmentMetadata.getProperty( "amount" ).getValue(); SimpleValue currencyMetadata = (SimpleValue) amountMetadata.getProperty( "currency" ).getValue(); CustomType currencyType = (CustomType) currencyMetadata.getType(); int[] currencySqlTypes = currencyType.sqlTypes( metadata ); assertEquals( 1, currencySqlTypes.length ); assertJdbcTypeCode( Types.VARCHAR, currencySqlTypes[0] ); } finally { StandardServiceRegistryBuilder.destroy( ssr ); } } }
int elementSpan = collectionBinding.getElement().getColumnSpan(); elementColumnAliases = new String[elementSpan]; elementColumnNames = new String[elementSpan]; int indexSpan = indexedCollection.getIndex().getColumnSpan(); boolean[] indexColumnInsertability = indexedCollection.getIndex().getColumnInsertability(); boolean[] indexColumnUpdatability = indexedCollection.getIndex().getColumnUpdateability();
public int getColumnSpan() { return value.getColumnSpan(); }
public int getColumnSpan() { return value.getColumnSpan(); }
public int getColumnSpan() { return value.getColumnSpan(); }
public int getColumnSpan() { return value.getColumnSpan(); }
public int getColumnSpan() { return value.getColumnSpan(); }
private boolean isFormula(Property field) { Value value = field.getValue(); boolean foundFormula = false; if(value!=null && value.getColumnSpan()>0) { Iterator<Selectable> columnIterator = value.getColumnIterator(); while ( columnIterator.hasNext() ) { Selectable element = columnIterator.next(); if(!(element instanceof Formula)) { return false; } else { foundFormula = true; } } } else { return false; } return foundFormula; }
private boolean isFormula(Property field) { Value value = field.getValue(); boolean foundFormula = false; if(value!=null && value.getColumnSpan()>0) { Iterator<Selectable> columnIterator = value.getColumnIterator(); while ( columnIterator.hasNext() ) { Selectable element = columnIterator.next(); if(!(element instanceof Formula)) { return false; } else { foundFormula = true; } } } else { return false; } return foundFormula; }
Value manyValue = oneProperty.getValue(); if ( manyValue != null && ( manyValue instanceof OneToOne || manyValue instanceof ManyToOne ) ) { if ( joinColumns.size() == manyValue.getColumnSpan() ) { isOtherSide = true; Iterator<?> it = manyValue.getColumnIterator();
Value manyValue = manyProperty.getValue(); if ( manyValue != null && manyValue instanceof ManyToOne ) { if ( joinColumns.size() == manyValue.getColumnSpan() ) { isOtherSide = true; Iterator<?> it = manyValue.getColumnIterator();
Value manyValue = manyProperty.getValue(); if ( manyValue != null && manyValue instanceof ManyToOne ) { if ( joinColumns.size() == manyValue.getColumnSpan() ) { isOtherSide = true; Iterator<?> it = manyValue.getColumnIterator();
private void makeOneToManyMapKeyColumnNullableIfNotInProperty( final XProperty property) { final org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) this.collection; if ( map.isOneToMany() && property.isAnnotationPresent( MapKeyColumn.class ) ) { final Value<?> indexValue = map.getIndex(); if ( indexValue.getColumnSpan() != 1 ) { throw new AssertionFailure( "Map key mapped by @MapKeyColumn does not have 1 column" ); } final MappedColumn mappedColumn = indexValue.getMappedColumns().get( 0 ); if ( mappedColumn.isFormula() ) { throw new AssertionFailure( "Map key mapped by @MapKeyColumn is a Formula" ); } final Column column = (Column) map.getIndex().getMappedColumns().get( 0 ); if ( !column.isNullable() ) { final PersistentClass persistentClass = ( ( OneToMany ) map.getElement() ).getAssociatedClass(); // check if the index column has been mapped by the associated entity to a property; // @MapKeyColumn only maps a column to the primary table for the one-to-many, so we only // need to check "un-joined" properties. if ( !propertyIteratorContainsColumn( persistentClass.getUnjoinedPropertyIterator(), column ) ) { // The index column is not mapped to an associated entity property so we can // safely make the index column nullable. column.setNullable( true ); } } } }