addChildVisitor(JpaId.class, new IdVisitor());
}
@Override
public boolean onStartNode(ProjectPath path) {
JpaAbstractEntity abstractEntity = (JpaAbstractEntity) path.getObject();
// * entity name
if (abstractEntity.getClassName() == null) {
return false;
}
if (abstractEntity instanceof JpaEntity) {
JpaEntity entity = (JpaEntity) abstractEntity;
if (entity.getName() == null) {
// use unqualified class name
String fqName = abstractEntity.getClassName();
int split = fqName.lastIndexOf('.');
entity.setName(split > 0 ? fqName.substring(split + 1) : fqName);
}
// * default table (see @Table annotation defaults, JPA spec 9.1.1)
if (entity.getTable() == null) {
JpaTable table = new JpaTable(AnnotationPrototypes.getTable());
// unclear whether we need to apply any other name transformations ...
// or even if we need to uppercase the name. Per default examples
// looks
// like we need. table.setName(entity.getName().toUpperCase());
table.setName(entity.getName());
entity.setTable(table);
}
}
if (abstractEntity.getAttributes() == null) {
abstractEntity.setAttributes(new JpaAttributes());
}
// * default persistent fields
JpaClassDescriptor descriptor = abstractEntity.getClassDescriptor();
AccessType access = abstractEntity.getAccess();
if (access == null) {
access = ((JpaEntityMap) path.getRoot()).getAccess();
abstractEntity.setAccess(access);
}
if (access == AccessType.PROPERTY) {
for (JpaPropertyDescriptor candidate : descriptor
.getPropertyDescriptors()) {