# JPA DATA TO DTO TO JSON ( Modelmapper & lombock )
# JPA DATA TO DTO TO JSON ( Modelmapper & lombock )
by jihoon kim
HTML
<h1> JPA DATA TO DTO TO JSON ( Modelmapper & lombock )</h1>
<pre>
# 참고 : http://wonwoo.ml/index.php/post/480
: https://docs.spring.io/spring-data/jpa/docs/1.4.1.RELEASE/reference/html/jpa.repositories.html
: https://github.com/Heo-Won-Chul/SpringPersonalProject
: http://modelmapper.org/ < modelmapper
: http://heowc.tistory.com/65 [허원철의 개발 블로그]
# Spring JPA는 Jackson 라이브러리를 이용한다.
Jackson Annotation : https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations
: http://www.baeldung.com/jackson-annotations
# Spring JPA DATA TO DTO TO JSON ( Modelmapper & lombock )
1. pom.xml 에 등록.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>0.7.5</version>
</dependency>
2. Entity 생성.
@Data
@Entity
@Table(name = "NOTICE")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Notice implements Serializable {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "notice_seq")
private Long seq;
@NotNull
private String title;
@NotNull
private String content;
public Notice() {}
public Notice(String title, String content) {
this.title = title;
this.content = content;
}
}
3. Repository 생성.
@Repository
public interface NoticeRepository extends JpaRepository<Notice, Long> {
Notice findBySeq(Integer seq);
Page<Notice> findByTitleContaining(String title, Pageable pageable);
Page<Notice> findByContentContaining(String content, Pageable...