码迷,mamicode.com
首页 > 其他好文 > 详细

【JPA】query新对象 需要 构造函数

时间:2015-08-20 01:12:34      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

 

构造函数

 

    @Query("select g from Note g where id=?1" )
    Note findById(Long id);

    @Query("select new sample.jpa.domain.Note2(c.id,c.title,c.body,d.id) from Note c,Tag d where c.id=d.id")
    List<Note2> findTagid();

 

 

@Entity
public class Note2 {


    public Note2(Long id,String title,String body,Long tid){

        this.id=id;
        this.title = title;
        this.body = body;
        this.tid= tid;
    }

    @Id
    private Long id;

    private String title;

    private String body;

    public Long getTid() {
        return tid;
    }

    public void setTid(Long tid) {
        this.tid = tid;
    }

    private Long  tid;



    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }


}

 

【JPA】query新对象 需要 构造函数

标签:

原文地址:http://www.cnblogs.com/viewcozy/p/4743886.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!