mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor/findannotation (#1104)
* refactor: renamed findAnnotation method that searches recursive to findAnnotationRecursive * CHG: searching namedQueries & indices also recursive in superclasses * FIX: Using the AnnotationBase methods on several places and documented them
This commit is contained in:
committed by
Rob Bygrave
parent
e908d16ba8
commit
46cdc84e6b
@@ -67,7 +67,7 @@ public class AnnotationClass extends AnnotationParser {
|
||||
public void parseAttributeOverride() {
|
||||
|
||||
Class<?> cls = descriptor.getBeanType();
|
||||
AttributeOverride override = AnnotationBase.findAnnotation(cls, AttributeOverride.class);
|
||||
AttributeOverride override = AnnotationBase.findAnnotationRecursive(cls, AttributeOverride.class);
|
||||
if (override != null) {
|
||||
String propertyName = override.name();
|
||||
Column column = override.column();
|
||||
@@ -109,14 +109,14 @@ public class AnnotationClass extends AnnotationParser {
|
||||
private void read(Class<?> cls) {
|
||||
|
||||
// maybe doc store only so check for this before @Entity
|
||||
DocStore docStore = AnnotationBase.findAnnotation(cls, DocStore.class);
|
||||
DocStore docStore = AnnotationBase.findAnnotationRecursive(cls, DocStore.class);
|
||||
if (docStore != null) {
|
||||
descriptor.readDocStore(docStore);
|
||||
descriptor.setEntityType(EntityType.DOC);
|
||||
descriptor.setName(cls.getSimpleName());
|
||||
}
|
||||
|
||||
Entity entity = AnnotationBase.findAnnotation(cls, Entity.class);
|
||||
Entity entity = AnnotationBase.findAnnotationRecursive(cls, Entity.class);
|
||||
if (entity != null) {
|
||||
descriptor.setEntityType(EntityType.ORM);
|
||||
if (entity.name().isEmpty()) {
|
||||
@@ -126,27 +126,27 @@ public class AnnotationClass extends AnnotationParser {
|
||||
}
|
||||
}
|
||||
|
||||
Embeddable embeddable = AnnotationBase.findAnnotation(cls, Embeddable.class);
|
||||
Embeddable embeddable = AnnotationBase.findAnnotationRecursive(cls, Embeddable.class);
|
||||
if (embeddable != null) {
|
||||
descriptor.setEntityType(EntityType.EMBEDDED);
|
||||
descriptor.setName("Embeddable:" + cls.getSimpleName());
|
||||
}
|
||||
|
||||
Set<Index> indices = AnnotationBase.findAnnotations(cls, Index.class);
|
||||
Set<Index> indices = AnnotationBase.findAnnotationsRecursive(cls, Index.class);
|
||||
for (Index index : indices) {
|
||||
descriptor.addIndex(new IndexDefinition(index.columnNames(), index.name(), index.unique()));
|
||||
}
|
||||
|
||||
UniqueConstraint uc = AnnotationBase.findAnnotation(cls, UniqueConstraint.class);
|
||||
UniqueConstraint uc = AnnotationBase.findAnnotationRecursive(cls, UniqueConstraint.class);
|
||||
if (uc != null) {
|
||||
descriptor.addIndex(new IndexDefinition(uc.columnNames()));
|
||||
}
|
||||
|
||||
View view = AnnotationBase.findAnnotation(cls, View.class);
|
||||
View view = AnnotationBase.findAnnotationRecursive(cls, View.class);
|
||||
if (view != null) {
|
||||
descriptor.setView(view.name(), view.dependentTables());
|
||||
}
|
||||
Table table = AnnotationBase.findAnnotation(cls, Table.class);
|
||||
Table table = AnnotationBase.findAnnotationRecursive(cls, Table.class);
|
||||
if (table != null) {
|
||||
UniqueConstraint[] uniqueConstraints = table.uniqueConstraints();
|
||||
for (UniqueConstraint c : uniqueConstraints) {
|
||||
@@ -154,42 +154,42 @@ public class AnnotationClass extends AnnotationParser {
|
||||
}
|
||||
}
|
||||
|
||||
Draftable draftable = AnnotationBase.findAnnotation(cls, Draftable.class);
|
||||
Draftable draftable = AnnotationBase.findAnnotationRecursive(cls, Draftable.class);
|
||||
if (draftable != null) {
|
||||
descriptor.setDraftable();
|
||||
}
|
||||
|
||||
DraftableElement draftableElement = AnnotationBase.findAnnotation(cls, DraftableElement.class);
|
||||
DraftableElement draftableElement = AnnotationBase.findAnnotationRecursive(cls, DraftableElement.class);
|
||||
if (draftableElement != null) {
|
||||
descriptor.setDraftableElement();
|
||||
}
|
||||
|
||||
ReadAudit readAudit = AnnotationBase.findAnnotation(cls, ReadAudit.class);
|
||||
ReadAudit readAudit = AnnotationBase.findAnnotationRecursive(cls, ReadAudit.class);
|
||||
if (readAudit != null) {
|
||||
descriptor.setReadAuditing();
|
||||
}
|
||||
|
||||
History history = AnnotationBase.findAnnotation(cls, History.class);
|
||||
History history = AnnotationBase.findAnnotationRecursive(cls, History.class);
|
||||
if (history != null) {
|
||||
descriptor.setHistorySupport();
|
||||
}
|
||||
|
||||
DbComment comment = AnnotationBase.findAnnotation(cls, DbComment.class);
|
||||
DbComment comment = AnnotationBase.findAnnotationRecursive(cls, DbComment.class);
|
||||
if (comment != null) {
|
||||
descriptor.setDbComment(comment.value());
|
||||
}
|
||||
|
||||
UpdateMode updateMode = AnnotationBase.findAnnotation(cls, UpdateMode.class);
|
||||
UpdateMode updateMode = AnnotationBase.findAnnotationRecursive(cls, UpdateMode.class);
|
||||
if (updateMode != null) {
|
||||
descriptor.setUpdateChangesOnly(updateMode.updateChangesOnly());
|
||||
}
|
||||
|
||||
Cache cache = AnnotationBase.findAnnotation(cls, Cache.class);
|
||||
Cache cache = AnnotationBase.findAnnotationRecursive(cls, Cache.class);
|
||||
if (cache != null && !disableL2Cache) {
|
||||
descriptor.setCache(cache);
|
||||
}
|
||||
|
||||
Set<NamedQuery> namedQueries = AnnotationBase.findAnnotations(cls, NamedQuery.class);
|
||||
Set<NamedQuery> namedQueries = AnnotationBase.findAnnotationsRecursive(cls, NamedQuery.class);
|
||||
for (NamedQuery namedQuery : namedQueries) {
|
||||
descriptor.addNamedQuery(namedQuery.name(), namedQuery.query());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user