티스토리 뷰


* 환경

HIbernate 5


* Entity

개체 이름 NlpSys, 테이블명 nlp_sys 


import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.Id;

import javax.persistence.Table;


@Entity

@Table(name ="nlp_sys")

public class NlpSys {

@Id

@Column

public String k;

@Column

public String v;

public NlpSys() { 

}

public String getK() {

return k;

}

public void setK(String k) {

this.k = k;

}

public String getV() {

return v;

}

public void setV(String v) {

this.v = v;

}

}



* Dao

package com.cidog.nlp;


import java.util.List;


import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Repository;


import com.cidog.nlp.model.NlpSys;


@Repository

public class HomeDao {

public HomeDao() {

}

@Autowired

SessionFactory sf;

public SessionFactory getSf() {

return sf;

}


public void setSf(SessionFactory sf) {

this.sf = sf;

}


public List<NlpSys> getAllNlpSys() {

Session s=  sf.openSession();

List lst = s.createQuery("from NlpSys").list();

s.close();

return lst;

}

}




* Service

package com.cidog.nlp;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;


import com.cidog.nlp.model.NlpSys;


@Service

public class HomeService {


@Autowired

HomeDao dao;

public List<NlpSys> findAllNs() { 

List lst = dao.getAllNlpSys();

System.out.println("찾은 개체 : " + lst.size());

System.out.println(lst);

return lst;

}

}



공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함