package com.example.Spring.domain.user;
import com.example.Spring.domain.BaseTimeEntity;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Getter
@NoArgsConstructor
@Entity
public class User extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String email;
@Column
private String picture;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Role role;
@Builder
public User(String name, String email, String picture, Role role) {
this.name = name;
this.email = email;
this.picture = picture;
this.role = role;
}
public User update(String name, String picture) {
this.name = name;
this.picture = picture;
return this;
}
public String getRoleKey() {
return this.role.getKey();
}
}
User class를 Entity 해주고 실행했는데,

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "drop table if exists [*]user"; expected "identifier"; SQL statement:
와같은 에러가 발생해버렸다.
엄청난 삽질끝에 원인을 찾았는데,
Class 이름을 User로 만들어서 Entity로 user라는 테이블을 만들었고, 이유는 모르겠지만 이미 존재하고 있었다.
그래서 처음 @Entity 선언할때

이런식으로 @Table(name = "users")로 이름을 바꾸어주니깐 잘 작동했다.
에러는 해결했지만 왜인지 모르겠으나 이미 user 테이블이 만들어져있는것같다.
'오류 해결' 카테고리의 다른 글
| [Spring]WebSecurityConfigurerAdapter deprecate (0) | 2023.01.12 |
|---|
댓글