Java 类org.hibernate.annotations.Immutable 实例源码

项目:screensaver    文件:IsVersionedTester.java   
/**
 * Test that the entity is versioned, that the name of the version property is "version",
 * and that the version property is not nullable.
 */
private void testIsVersioned()
{

  org.hibernate.annotations.Entity entityAnnotation =
    _entityClass.getAnnotation(org.hibernate.annotations.Entity.class);
  if (entityAnnotation != null && ! entityAnnotation.mutable()) {
    return;
  }
  if (_entityClass.getAnnotation(Immutable.class) != null) {
    return;
  }

  ManagedType<? extends AbstractEntity> type = _entityManagerFactory.getMetamodel().managedType(_entityClass);
  SingularAttribute id = ((IdentifiableType) type).getId(((IdentifiableType) type).getIdType().getJavaType());
  assertTrue("hibernate class is versioned: " + _entityClass, ((IdentifiableType) type).hasVersionAttribute());

  assertFalse("version property is not nullable: " + _entityClass, ((IdentifiableType) type).getVersion(Integer.class).isOptional());
}
项目:lams    文件:PropertyBinder.java   
private void validateBind() {
    if ( property.isAnnotationPresent( Immutable.class ) ) {
        throw new AnnotationException(
                "@Immutable on property not allowed. " +
                        "Only allowed on entity level or on a collection."
        );
    }
    if ( !declaringClassSet ) {
        throw new AssertionFailure( "declaringClass has not been set before a bind" );
    }
}
项目:screensaver    文件:ModelIntrospectionUtil.java   
public static boolean isImmutableProperty(Class<? extends AbstractEntity> beanClass, PropertyDescriptor propertyDescriptor)
{
  org.hibernate.annotations.Entity entityAnnotation =
    beanClass.getAnnotation(org.hibernate.annotations.Entity.class);
  if (entityAnnotation != null && ! entityAnnotation.mutable()) {
    return true;
  }
  if (beanClass.getAnnotation(Immutable.class) != null) {
    return true;
  }
  Method getter = propertyDescriptor.getReadMethod();
  javax.persistence.Column columnAnnot = getter.getAnnotation(javax.persistence.Column.class);
  return columnAnnot != null && !columnAnnot.updatable();
}
项目:screensaver    文件:ModelIntrospectionUtil.java   
public static boolean isImmutableIgnoreTests(Class<? extends AbstractEntity> beanClass)
{
    return  beanClass.getAnnotation(Immutable.class) != null && beanClass.getAnnotation(IgnoreImmutabilityTest.class) != null;
}