use of com.manydesigns.elements.annotations.Updatable in project Portofino by ManyDesigns.
the class SessionFactoryBuilder method configureAnnotations.
protected void configureAnnotations(Table table, ConstPool constPool, AnnotationsAttribute classAnnotations) {
Annotation annotation;
annotation = new Annotation(javax.persistence.Table.class.getName(), constPool);
annotation.addMemberValue("name", new StringMemberValue(jpaEscape(table.getTableName()), constPool));
if (multiTenancyImplementation == null || multiTenancyImplementation.getStrategy() != MultiTenancyStrategy.SCHEMA) {
// Don't configure the schema name if we're using schema-based multitenancy
String schemaName = table.getSchema().getActualSchemaName();
annotation.addMemberValue("schema", new StringMemberValue(jpaEscape(schemaName), constPool));
}
classAnnotations.addAnnotation(annotation);
annotation = new Annotation(Entity.class.getName(), constPool);
annotation.addMemberValue("name", new StringMemberValue(table.getActualEntityName(), constPool));
classAnnotations.addAnnotation(annotation);
table.getAnnotations().forEach(ann -> {
Class annotationClass = ann.getJavaAnnotationClass();
if (javax.persistence.Table.class.equals(annotationClass) || Entity.class.equals(annotationClass)) {
logger.warn("@Table or @Entity specified on table {}, skipping annotation {}", table.getQualifiedName(), annotationClass);
return;
}
Annotation classAnn = convertAnnotation(constPool, ann);
if (classAnn != null) {
classAnnotations.addAnnotation(classAnn);
}
if (annotationClass == Updatable.class && !((Updatable) ann.getJavaAnnotation()).value()) {
classAnnotations.addAnnotation(new Annotation(Immutable.class.getName(), constPool));
}
});
}
Aggregations