zoukankan      html  css  js  c++  java
  • 【JPA】query新对象 需要 构造函数

    构造函数

        @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;
        }
    
    
    }
  • 相关阅读:
    洛谷 [SDOI2015]约数个数和 解题报告
    multiset-count
    multiset-begin
    multiset-begin
    set-value_comp
    set-value_comp
    multiset-constructors
    multiset-constructors
    set-upper_bound
    set-upper_bound
  • 原文地址:https://www.cnblogs.com/viewcozy/p/4743886.html
Copyright © 2011-2022 走看看