hibernate之formula

若porperty指定formula属性,即该属性没有对应数据列,属性值由formula对应的SQL表达式生成.

xml形式:<property name="" formula="(select concat(tn.title,tn.content) from NEWS tn where tn.id=id)"></property>

注解形式:private String userName;

    @Formula("(select t.user_name frome user_info t where t.user_id = user_id)")

    public String getUserName(){

      return username;

    }

 

 

 

 

posted @ 2017-02-22 09:44  秋风清雾露开  阅读(161)  评论(0编辑  收藏  举报