EntityUtils.java 文件源码

java
阅读 44 收藏 0 点赞 0 评论 0

项目:sop4j-dbutils 作者:
/**
 * Given an entity, returns the table name for the entity.
 * @param entity the entity to lookup.
 * @return the name of the table for the entity.
 */
public static String getTableName(final Class<?> entity) {
    final Entity annotation = entity.getAnnotation(Entity.class);

    if(annotation == null) {
        throw new IllegalArgumentException(entity.getName() + " does not have the Entity annotation");
    }

    final Table table = entity.getAnnotation(Table.class);

    // get the table's name from the annotation
    if(table != null && !table.name().isEmpty()) {
        return table.name();
    } else {
        return entity.getSimpleName();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号