From 5d8228b09ad0dc29c4a1971fb54d4ebecb85fa6b Mon Sep 17 00:00:00 2001 From: geek Date: Fri, 23 Jun 2017 14:28:18 +0900 Subject: [PATCH] construct method added --- .../overflow/module/member/dao/MemberDAO.java | 5 +++-- .../module/member/dao/MemberDAOTest.java | 21 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java b/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java index aee7942..47cebbe 100644 --- a/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java +++ b/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java @@ -3,6 +3,7 @@ package com.loafle.overflow.module.member.dao; import com.loafle.overflow.module.member.model.Member; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; /** @@ -10,6 +11,6 @@ import org.springframework.stereotype.Repository; */ @Repository public interface MemberDAO extends JpaRepository { -// @Query("SELECT m FROM MEMBER m WHERE m.email = :email") -// Member findByEmail(Member member); + @Query("select m from Member m WHERE m.email = :#{#m2.email}") + Member findByEmail(@Param("m2") Member member); } diff --git a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java index 17ca511..213584c 100644 --- a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java @@ -31,7 +31,26 @@ public class MemberDAOTest { m.setPwSalt("salktttt"); m.setPhone("000-000-0000"); m.setEmail("insanity1@loafle.com"); - m.setStatus(new MetaMemberStatus()); + m.setStatus(new MetaMemberStatus((short)1)); repo.save(m); } + + @Test + public void TestFindByEmail() { + Member m = new Member(); + + m.setEmail("insanity1@loafle.com"); + + Member mm = this.repo.findByEmail(m); + + System.out.println(mm.getCompanyName()); + } + @Test + public void updateMember() { + Member m = this.repo.findOne((long)1); + + m.setPw("123123123"); + m.setStatus(new MetaMemberStatus((short)2)); + this.repo.save(m); + } } \ No newline at end of file