Example usage for org.hibernate.mapping Property isOptional

List of usage examples for org.hibernate.mapping Property isOptional

Introduction

In this page you can find the example usage for org.hibernate.mapping Property isOptional.

Prototype

public boolean isOptional() 

Source Link

Usage

From source file:org.wicketopia.persistence.hibernate.decorator.HibernatePropertyDecorator.java

License:Apache License

public void decorate(PropertyMetaData propertyMetaData) {
    WicketopiaPropertyFacet facet = WicketopiaPropertyFacet.get(propertyMetaData);
    final PersistentClass classMapping = findClassMapping(propertyMetaData.getBeanMetaData());
    if (classMapping != null) {
        final Property property = classMapping.getProperty(propertyMetaData.getPropertyDescriptor().getName());

        if (property == null) {
            return;
        } else if (!(property.getValue() instanceof SimpleValue)) {
            facet.setIgnored(true);// w w w.j a  v  a2  s  . c  om
        } else if (ignoreIdentifiers && property.equals(classMapping.getIdentifierProperty())) {
            facet.setIgnored(true);
        } else if (property.equals(classMapping.getVersion())) {
            facet.setIgnored(true);
        }

        if (!property.isOptional()) {
            facet.setRequired(Context.ALL_CONTEXTS, true);
        }
    }
}