public static String getEntityName(Class entity) { if (mappedName.get(entity) != null) { return mappedName.get(entity); } String name = null; Table table = (Table) entity.getAnnotation(Table.class); if (table != null && table.name() != null && !table.name().isEmpty()) { name = table.name(); } else { Entity entityAnnotation = (Entity) entity.getAnnotation(Entity.class); if (entityAnnotation != null && entityAnnotation.name() != null && !entityAnnotation.name().isEmpty()) { name = entityAnnotation.name(); } else { name = entity.getSimpleName(); } } mappedName.put(entity, name); return name; }
private void putTableDeclaration(AnnotationInfo ai, Class<?> c) { Table table = c.getAnnotation(Table.class); if (table != null) { if (table.name() == null) throw new PersistenceException("You must specify a name= for @Table on " + c.getName()); ai.setDomainName(table.name()); } }