首页 新闻 会员 周边

java:怎么获取@entity对应的表映射?

0
悬赏园豆:15 [已关闭问题] 关闭于 2017-10-27 09:08
@Entity
@Table(name = "table_recode")
public class Recode extends AbstractEntity {
    private static final long serialVersionUID = 1L;

    /** ID */
    private Long id;
    /** 来源APP */
    private Long appId;
    /** 会话code */
    private String sessionCode;
}

(不是自己写反射实现)  JPA/hibernate中

通过传递 Recode.class 就可以得到, 这张表叫"TABLE_RECODE", 其中appId对应的数据库字段是"app_id".

我看了下代码,  类似: 

org.hibernate.internal.SessionFactoryImpl.getEntityPersister(String entityName)

(至于为什么不用SessionFactoryImpl, 正在研究怎么注入好....)

淡丶无欲的主页 淡丶无欲 | 初学一级 | 园豆:87
提问于:2017-08-28 14:01
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册