applyDDL( "", persistentClass, clazz, factory, groups, true, dialect );
applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups,
public static void applyDDL(Collection<PersistentClass> persistentClasses, Properties properties) { ValidatorFactory factory = getValidatorFactory( properties ); Class<?>[] groupsArray = new GroupsPerOperation( properties ).get( GroupsPerOperation.Operation.DDL ); Set<Class<?>> groups = new HashSet<Class<?>>( Arrays.asList( groupsArray ) ); for ( PersistentClass persistentClass : persistentClasses ) { final String className = persistentClass.getClassName(); if ( className == null || className.length() == 0) continue; Class<?> clazz; try { clazz = ReflectHelper.classForName( className, TypeSafeActivator.class ); } catch ( ClassNotFoundException e ) { throw new AssertionFailure( "Entity class not found", e); } try { applyDDL( "", persistentClass, clazz, factory, groups, true ); } catch (Exception e) { logger.warn( "Unable to apply constraints on DDL for " + className, e ); } } }
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 } } }
@SuppressWarnings( {"UnusedDeclaration"}) public static void applyDDL(Collection<PersistentClass> persistentClasses, Properties properties, Dialect dialect) { ValidatorFactory factory = getValidatorFactory( properties ); Class<?>[] groupsArray = new GroupsPerOperation( properties ).get( GroupsPerOperation.Operation.DDL ); Set<Class<?>> groups = new HashSet<Class<?>>( Arrays.asList( groupsArray ) ); for ( PersistentClass persistentClass : persistentClasses ) { final String className = persistentClass.getClassName(); if ( className == null || className.length() == 0 ) { continue; } Class<?> clazz; try { clazz = ReflectHelper.classForName( className, TypeSafeActivator.class ); } catch ( ClassNotFoundException e ) { throw new AssertionFailure( "Entity class not found", e ); } try { applyDDL( "", persistentClass, clazz, factory, groups, true, dialect ); } catch (Exception e) { LOG.unableToApplyConstraints( className, e ); } } }
@SuppressWarnings( {"UnusedDeclaration"}) public static void applyDDL(Collection<PersistentClass> persistentClasses, Properties properties, Dialect dialect) { ValidatorFactory factory = getValidatorFactory( properties ); Class<?>[] groupsArray = new GroupsPerOperation( properties ).get( GroupsPerOperation.Operation.DDL ); Set<Class<?>> groups = new HashSet<Class<?>>( Arrays.asList( groupsArray ) ); for ( PersistentClass persistentClass : persistentClasses ) { final String className = persistentClass.getClassName(); if ( className == null || className.length() == 0 ) { continue; } Class<?> clazz; try { clazz = ReflectHelper.classForName( className, TypeSafeActivator.class ); } catch ( ClassNotFoundException e ) { throw new AssertionFailure( "Entity class not found", e ); } try { applyDDL( "", persistentClass, clazz, factory, groups, true, dialect ); } catch (Exception e) { LOG.unableToApplyConstraints( className, e ); } } }
applyDDL( "", entityMapping, clazz, factory, groups, true, dialect );
applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups,
applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups,
applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups,