JAVA/spring

[1028 JPA]에러모음

error 1.

문제 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
검색 에러 발생 시 Eclipse Run Configurations에서 Arguments에 --debug 추가  출처  kamsi76.tistory.com/entry/%EC%8B%9C%EC%9E%91
해결 application.properties 에 설정추가. 
logging.level.org.springframework= debug
logging.level.org.springframework.web= debug

error 2. 

문제 defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
해결 DB 서버 재기동 & 상태점검 >> 도커재기동  restart docker

 

error3

문제 org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction

중략
Caused by: javax.validation.ConstraintViolationException: Validation failed for classes [com.today10sec.diary.customize.model.Customer] during persist time for groups [javax.validation.groups.Default, ] List of constraint violations:[ ConstraintViolationImpl{interpolatedMessage='반드시 최소값 6과(와) 최대값 12 사이의 길이이어야 합니다.', propertyPath=password, rootBeanClass=class com.today10sec.diary.customize.model.Customer, messageTemplate='{org.hibernate.validator.constraints.Length.message}'} ] at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:140) 
해결 스프링시큐리티 적용하면서 password 길이수가 늘었는데 생각못해서. 수정
validate range  change

error4

문제 jpa count NonUniqueResultException: query did not return a unique result: 31

중략

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXXController': Unsatisfied dependency expressed through field 'XXXControllerService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultXXXControllerService': Injection of autowired dependencies failed; nested exception is org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 31; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 31

해결 count 를 사용하려고 했는데  이렇게 인간적인 jpa 일쭐이야.
count 밖에 쓸일이 없는 쿼리라 count로 정의 하려고 했는데.. 고민될정도로 count사용이 지저분했다.  
1. 리턴값은 List<long> 
그리고 조건을 group by 한 거였는데   list 의 길이가 내가 원한 값(그룹바이한 조건 값 31)이고  리스트 안에 long 은 반복되는 횟수(3)였다.   

error5

문제 Invocation of init method failed; nested exception is org.hibernate.AnnotationException: A Foreign key refering co   
중략  
has the wrong number of column. should be 2

해결 멀티키를 가진 model 을 join 할때 해당 멀티키를 각각  @joinColumn 선언필요
... 우선선언은했는데.. sn 한 컬럼만조인하면되는데.. 쓰레기 컬럼이 생겨버림...

error6

문제 Unable to find column with logical name XXXX:  in org.hibernate.mapping.Table(XXXX) and its related supertables and secondary tables
해결 @column @joinColumn 선언 검토 필요
테이블 구조를 변경하면서 오타발생

error7  >> 추가 검토 필요. 

문제 2022-06-18 17:40:42.159 ERROR 17664 --- [p-nio-80-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper   : HikariPool-1 - Connection is not available, request timed out after 30012ms.
해결 https://techblog.woowahan.com/2664/
쓰레드 1개, 히카리 Maximum pool size 1개 -> 하나의 task 에 동시 요구되는 connection 2개

풀싸이즈 = 트랜젝션 x  (커넥션-1) +1
풀사이즈 = 트랜젝션 (커넥션-1) + 트랜젝션/2

  java.lang.Exception: Apparent connection leak detected
  spring.datasource.hikari.leak-detection-threshold=240000

클일일세... https://docs.openkm.com/kcenter/view/okmkb/warning-in-update-or-creation-stage-javalangexception-apparent-connection-leak-detected.html

https://do-study.tistory.com/97