@SuppressWarnings("unchecked") private static boolean applyNotNull(Property property, ConstraintDescriptor<?> descriptor) { boolean hasNotNull = false; if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) { // single table inheritance should not be forced to null due to shared state if ( !( property.getPersistentClass() instanceof SingleTableSubclass ) ) { //composite should not add not-null on all columns if ( !property.isComposite() ) { final Iterator<Selectable> itr = property.getColumnIterator(); while ( itr.hasNext() ) { final Selectable selectable = itr.next(); if ( Column.class.isInstance( selectable ) ) { Column.class.cast( selectable ).setNullable( false ); } else { LOG.debugf( "@NotNull was applied to attribute [%s] which is defined (at least partially) " + "by formula(s); formula portions will be skipped", property.getName() ); } } } } hasNotNull = true; } return hasNotNull; }
if ( !property.isComposite() ) { return null; if ( !property.isComposite() ) { return null;
if ( !property.isComposite() ) { return null; if ( !property.isComposite() ) { return null;
if ( referencedProperty.isComposite() ) { Property property = createComponentProperty( referencedPersistentClass, isExplicitReference, columnByReferencedName, index, referencedProperty ); component.addProperty( property );
if ( !property.isComposite() ) { return null; if ( !property.isComposite() ) { return null;
public void generateSecondPass(String entityName, PersistentClass persistentClass) { final Component identifierMapper = persistentClass.getIdentifierMapper(); final Property identifierProperty = persistentClass.getIdentifierProperty(); if ( identifierMapper != null ) { generateSecondPass( entityName, identifierMapper ); } else if ( identifierProperty != null && identifierProperty.isComposite() ) { final Component component = (Component) identifierProperty.getValue(); generateSecondPass( entityName, component ); } }
private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) { while ( propertyIterator.hasNext() ) { Property prop = (Property) propertyIterator.next(); String propname = path == null ? prop.getName() : path + "." + prop.getName(); if ( prop.isComposite() ) { Component component = (Component) prop.getValue(); Iterator compProps = component.getPropertyIterator(); internalInitSubclassPropertyAliasesMap( propname, compProps ); } else { String[] aliases = new String[prop.getColumnSpan()]; String[] cols = new String[prop.getColumnSpan()]; Iterator colIter = prop.getColumnIterator(); int l = 0; while ( colIter.hasNext() ) { Selectable thing = (Selectable) colIter.next(); aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() ); cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas? l++; } subclassPropertyAliases.put( propname, aliases ); subclassPropertyColumnNames.put( propname, cols ); } } }
propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect ); if ( property.isComposite() && propertyDesc.isCascaded() ) { Class<?> componentClass = ( (Component) property.getValue() ).getComponentClass();
Property referencedComponentProperty = propertyIterator.next(); if ( referencedComponentProperty.isComposite() ) { Property componentProperty = createComponentProperty( referencedValue.getOwner(), isExplicitReference, columnByReferencedName, index, referencedComponentProperty ); value.addProperty( componentProperty );
else if ( attributeContext.getPropertyMapping().isComposite() ) {
private static boolean applyNotNull(Property property, ConstraintDescriptor<?> descriptor) { boolean hasNotNull = false; if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) { if ( ! ( property.getPersistentClass() instanceof SingleTableSubclass ) ) { //single table should not be forced to null if ( !property.isComposite() ) { //composite should not add not-null on all columns @SuppressWarnings( "unchecked" ) Iterator<Column> iter = (Iterator<Column>) property.getColumnIterator(); while ( iter.hasNext() ) { iter.next().setNullable( false ); hasNotNull = true; } } } hasNotNull = true; } return hasNotNull; }
else if ( idProp.isComposite() ) {
if ( !property.isComposite() ) return null; property = ( (Component) property.getValue() ).getProperty( element ); if ( !property.isComposite() ) return null; property = ( (Component) property.getValue() ).getProperty( element );
if ( ! property.isComposite() ) return null; property = ( ( Component ) property.getValue() ).getProperty( element ); if ( ! property.isComposite() ) return null; property = ( (Component) property.getValue() ).getProperty( element );
if ( !property.isComposite() ) return null; property = ( (Component) property.getValue() ).getProperty( element ); if ( !property.isComposite() ) return null; property = ( (Component) property.getValue() ).getProperty( element );
private static void applyDDL(String prefix, PersistentClass persistentClass, Class<?> clazz, ValidatorFactory factory, Set<Class<?>> groups, boolean activateNotNull) { final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass( clazz ); //no bean level constraints can be applied, go to the properties for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) { Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() ); boolean hasNotNull = false; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull ); if ( property.isComposite() && propertyDesc.isCascaded() ) { Class<?> componentClass = ( ( Component ) property.getValue() ).getComponentClass(); /* * we can apply not null if the upper component let's us activate not null * and if the property is not null. * Otherwise, all sub columns should be left nullable */ final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull; applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups, canSetNotNullOnColumns ); } //FIXME add collection of components } } }
if ( referencedProperty.isComposite() ) { throw new AssertionFailure( "Unexpected nested component on the referenced entity when mapping a @MapsId: " + referencedEntityName);
@SuppressWarnings("unchecked") public void apply(Property property) { if ( ! ( property.getPersistentClass() instanceof SingleTableSubclass ) ) { //single table should not be forced to null if ( !property.isComposite() ) { //composite should not add not-null on all columns Iterator<Column> iter = (Iterator<Column>) property.getColumnIterator(); while ( iter.hasNext() ) { iter.next().setNullable( false ); } } } } }
@SuppressWarnings("unchecked") public void apply(Property property) { if ( ! ( property.getPersistentClass() instanceof SingleTableSubclass ) ) { //single table should not be forced to null if ( !property.isComposite() ) { //composite should not add not-null on all columns Iterator<Column> iter = (Iterator<Column>) property.getColumnIterator(); while ( iter.hasNext() ) { iter.next().setNullable( false ); } } } } }
@SuppressWarnings("unchecked") public void apply(Property property) { if ( ! ( property.getPersistentClass() instanceof SingleTableSubclass ) && ! ( property.getValue() instanceof Collection ) ) { //single table should not be forced to null if ( !property.isComposite() ) { //composite should not add not-null on all columns Iterator<Column> iter = (Iterator<Column>) property.getColumnIterator(); while ( iter.hasNext() ) { iter.next().setNullable( false ); } } } }