本文整理汇总了Java中org.hibernate.annotations.Immutable类的典型用法代码示例。如果您正苦于以下问题:Java Immutable类的具体用法?Java Immutable怎么用?Java Immutable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Immutable类属于org.hibernate.annotations包,在下文中一共展示了Immutable类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIsVersioned
import org.hibernate.annotations.Immutable; //导入依赖的package包/类
/**
* 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());
}
示例2: validateBind
import org.hibernate.annotations.Immutable; //导入依赖的package包/类
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" );
}
}
示例3: isImmutableProperty
import org.hibernate.annotations.Immutable; //导入依赖的package包/类
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();
}
示例4: isImmutableIgnoreTests
import org.hibernate.annotations.Immutable; //导入依赖的package包/类
public static boolean isImmutableIgnoreTests(Class<? extends AbstractEntity> beanClass)
{
return beanClass.getAnnotation(Immutable.class) != null && beanClass.getAnnotation(IgnoreImmutabilityTest.class) != null;
}