Languages/SQL

[Error] H2 데이터베이스 최신 버전

잔망루피 2022. 3. 31. 19:46
반응형

H2 데이터베이스를 다시 설치하면서 이전에 잘 동작했던 테스트 코드가 실행되지 않았다. 

 

 

💕 해결

2.1.210, 2.0.206 두 버전 다 최신 버전이라서 잘 안됨.

1.4.200 버전을 쓰니까 잘 된다.

최신 버전 사용하면 이전에 잘 되던 코드도 안 되는 경우가 많다는 것을 느꼈다😂

첫 번째 문제) user가 identifier라면서 테이블명이 user로 안 만들어진다.

엔티티에 @Table(name="users")도 붙여봤지만, 다른 에러가 뜬다.

두 번째 문제) id가 null

insert into post (id, created_date, modified_date, author, content, title, view) values (null, ?, ?, ?, ?, ?, ?)

@GeneratedValue(strategy= GenerationType.IDENTITY)를 id 필드에 줬으니까 자동으로 증가되는건데...

테이블 생성할 때 id 필드에 generated by default as identity도 넣어줬는데

왜 null인건지😥

세 번째 문제) 

org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [insert into user (email, enabled, name, password, phone, username) values (?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement

org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement

 

 

 

참고 👇

https://www.inflearn.com/questions/17219

 

기존 테이블이 삭제되지 않는 문제.. - 인프런 | 질문 & 답변

안녕하세요 영한님 강좌를 보며 예제를 따라하던중 제 프로젝트가 영한님과 다르게 실행되는것 같아 질문을 올립니다 hibernate.hbm2ddl.auto = create 인 상황에서 프로젝트를 실행하면 기존에 생성되

www.inflearn.com

 

https://dogcowking.tistory.com/60

 

InvalidDataAccessResourceUsageException: could not retrieve snapshot

org.springframework.dao.InvalidDataAccessResourceUsageException: could not retrieve snapshot ;; 테이블 생성 안되어있거나 ;; 하이버네이트에서 지정한 컬럼이 없는거 - 아니면 @column name 또는 hbm.xml..

dogcowking.tistory.com

 

반응형