/**
* 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());
}
java类org.hibernate.annotations.Immutable的实例源码
IsVersionedTester.java 文件源码
项目:screensaver
阅读 37
收藏 0
点赞 0
评论 0
PropertyBinder.java 文件源码
项目:lams
阅读 42
收藏 0
点赞 0
评论 0
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" );
}
}
ModelIntrospectionUtil.java 文件源码
项目:screensaver
阅读 41
收藏 0
点赞 0
评论 0
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();
}
ModelIntrospectionUtil.java 文件源码
项目:screensaver
阅读 42
收藏 0
点赞 0
评论 0
public static boolean isImmutableIgnoreTests(Class<? extends AbstractEntity> beanClass)
{
return beanClass.getAnnotation(Immutable.class) != null && beanClass.getAnnotation(IgnoreImmutabilityTest.class) != null;
}