construct method added

This commit is contained in:
geek 2017-06-23 14:28:18 +09:00
parent 80452e4ff3
commit 5d8228b09a
2 changed files with 23 additions and 3 deletions

View File

@ -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<Member, Long> {
// @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);
}

View File

@ -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);
}
}