jmrandomname
@jmrandomname
Reviews Written
3
Average Rating
5.0
Posts
Q&A
@Transactional ์ฌ์ฉ
๊ฐ์ ๋ณด๋ค๊ฐ Transactional ๊ด๋ จํด์ ์ง๋ฌธ์ด ์์ต๋๋ค.๋ง์ฝ A๊ฐ์ฒด๊ฐ B๊ฐ์ฒด๋ฅผ oneToMany๊ด๊ณ(lazy loading)๋ก ๊ฐ์ง๊ณ ์์ ๋ํ ์คํธ ์ฝ๋์์ A ์ํฐํฐ๋ฅผ ๋ถ๋ฌ์ค๊ณ B๊ฐ์ฒด์ ์ ๊ทผ์ ํ๊ฒ ๋๋ฉด ์์์ฑ ์ปจํ ์คํธ๊ฐ ์ข ๋ฃ ๋์ด ๋ฒ๋ ค์ ์ง์ฐ๋ก๋ฉ ๊ฐ์ฒด๋ฅผ ์ด๊ธฐํ ํ ์ ์๊ฒ ๋๋๋ฐ ์ด๋ ์ด ๋ฌธ์ ๋ฅผ ์ด๋ป๊ฒ ํด๊ฒฐํ ์ ์๋์?ํ ์คํธ๋ฅผ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์ง์ผํ๋์ง ์๋๋ฉด ๊ทธ๋ฅ ์ฝ๋๋ฅผ ํ ์คํธ ๊ฐ๋ฅํ ์ฝ๋๋ก ์ง์ง ์์๊ฑด์ง ํํ๋ ์๊ฒฌ์ด ๊ถ๊ธํฉ๋๋ค!
- 1
- 3
- 473
Q&A
repository mocking ๋ฌธ์
์ง์๋ ํน์ ๋ด๋ถ๊ตฌํ์ด ๋ ธ์ถ๋๋ค๋ ๊ฒ ์ด๋ค ๊ฑด์ง ์ ์ดํด๊ฐ ์ ๊ฐ๋๋ฐ ์กฐ๊ธ ๋ ์ค๋ช ํด์ฃผ์ค ์ ์๋์?๋ชจํนํ๋ ๊ณผ์ ์์ ๋ ธ์ถ๋๋ ์ฝ๋ ๋ง์ํ์๋๊ฑด๊ฐ์?
- 1
- 2
- 1.2K
Q&A
์คํ๋ง ๋ฐ์ดํฐ JPA ์ EntityManager
์ฝ๋๋ ๊ฐ์์ ๊ด๋ จ๋ ๋ถ๋ถ์ด ์๋์ง๋ง ์ ๊ฐ ํ ์ง๋ฌธ์ ๊ฐ์์ ๊ด๋ จ๋ ์ง๋ฌธ์ธ ๊ฒ ๊ฐ์์ ์ง๋ฌธ ์ฌ๋ ค๋ดค์ต๋๋ค. ์ฃผ์ ์ ๋ฒ์ด๋ฌ๋ค๋ฉด ์ฃผ์ํ๋๋ก ํ๊ฒ ์ต๋๋ค. ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค.!!
- 0
- 4
- 445
Q&A
์คํ๋ง ๋ฐ์ดํฐ JPA ์ EntityManager
์๋ ํ์ธ์ ๋ต๊ธ์ด ๋ฆ์์ต๋๋ค. ๋จผ์ ๋์ ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค. ์์ค์ฝ๋ https://drive.google.com/file/d/1nlV_PJWleiY05kyEMMkkGV_zqpENjrbM/view?usp=sharing ์คํ๋ฐฉ๋ฒ : mysql DB๋ฅผ ์ค๋นํด ์ฃผ์๊ณ application.yml ํ์ผ์ datasource๋ฅผ ๋ฃ์ด์ฃผ์ธ์. ๊ทธ๋ฆฌ๊ณ main๋ฌธ์ ์คํํ์๋ฉด ๋ฉ๋๋ค. 2.๋ฌธ์ ๋ฅผ ํ์ธํ๋ ๋ฒ ๋ฉ์ธ ๋ฌธ์ ์คํํ์๋ฉด ๋ฐ๋ก ์๋ฌ๊ฐ ๋์ต๋๋ค. ์ ๊ฐ ์ง๋ฌธ๋๋ฆฌ๋ ๊ฒ์ JPARepository์ EntityManager๋ฅผ ํจ๊ป ์ธ ์ ์๋ ๋ฐฉ๋ฒ ์ ๋๋ค. ํ๋ก์ ํธ์์ WorkerRepository์ ๊ฐ์๋ฉด CustomRepository๋ฅผ ์์ํ ๊ฒ์ ๋ณผ ์ ์์ ๊ฒ ์ ๋๋ค. CustomRepository๋ฅผ ๊ตฌํํ ๊ตฌํ์ฒด CustomRepositoryImp์ EntityManager๋ฅผ ์ฃผ์ ๋ฐ๊ณ em์ ์ฐ๋ ค๊ณ ํ์ง๋ง ์ ์๋๋ ์ํ์ ๋๋ค. ๊ฐ์ฌํฉ๋๋ค.
- 0
- 4
- 445
Q&A
์คํ๋ง ๋ฐ์ดํฐ JPA ์ EntityManager
๋ต public interface WorkerRepository extends JpaRepository,CustomRepository{ Worker findByName(String name); } public interface CustomRepository { void customMethod(); } @Service public class CustomRepositoryImp implements CustomRepository{ @Autowired private EntityManager em; @Override public void customMethod() { System.out.println("test"); } } ์๋ฌ ๋ฉ์ธ์ง Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'workerService' defined in file [C:\Users\admin\git\rebuild\build\classes\java\main\com\rebuild\service\WorkerService.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workerRepository' defined in com.rebuild.repository.WorkerRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void com.rebuild.repository.CustomRepository.customMethod()! Reason: Failed to create query for method public abstract void com.rebuild.repository.CustomRepository.customMethod()! No property customMethod found for type Worker!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.rebuild.repository.CustomRepository.customMethod()! No property customMethod found for type Worker! ์ดํ๋ฆฌ์ผ์ด์ ์ด ์คํํ๋์ง ์ ์ ์๋ฌ๋ ๋๋ ์ํ ์ ๋๋ค.
- 0
- 4
- 445
Q&A
dto์์์ join์ง๋ฌธ์ด์์ต๋๋ค.
join์ด ๋๋ ์ํฐํฐ ํ๋๊ฐ select ํ๋ก์ ์ ์ ์์ผ๋ฉด ํ๋ก์ ๊ฐ์ฒด๊ฐ ์ ๋ค์ด๊ฐ๊ณ ํค๋น ๊ฐ DB ์กฐํํด์ ์์์ฑ ์ปจํ ์คํธ์ ๊ฐ์ด ๋ค์ด๊ฐ๋ ๊ฑด๊ฐ์?
- 13
- 3
- 500




