/**
* Validates the provided class' annotations.
* Currently the only validation performed is for @Id & @SpaceId annotations
* that must be declared on the same getter.
*/
private void validateClassAnnotations(Class<?> type) {
// Validation is only relevant for Entities
if (type.getAnnotation(Entity.class) == null)
return;
for (Method getter : type.getMethods()) {
if (!getter.getName().startsWith("get"))
continue;
SpaceId spaceId = getter.getAnnotation(SpaceId.class);
boolean hasJpaId = getter.getAnnotation(Id.class) != null || getter.getAnnotation(EmbeddedId.class) != null;
if (spaceId != null || hasJpaId) {
if (!hasJpaId || spaceId == null)
throw new IllegalArgumentException("SpaceId and Id annotations must both be declared on the same property in JPA entities in type: " + type.getName());
if (spaceId.autoGenerate()) {
GeneratedValue generatedValue = getter.getAnnotation(GeneratedValue.class);
if (generatedValue == null || generatedValue.strategy() != GenerationType.IDENTITY)
throw new IllegalArgumentException(
"SpaceId with autoGenerate=true annotated property should also have a JPA GeneratedValue annotation with strategy = GenerationType.IDENTITY.");
}
break;
}
}
}
StoreManager.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:xap-openspaces
作者:
评论列表
文章目录