[JPA] org.hibernate.id.IdentifierGenerationException

JohnΒ·2023λ…„ 6μ›” 14일
0

μ—λŸ¬ λ©”λͺ¨πŸ₯€

λͺ©λ‘ 보기
8/9
post-thumbnail

org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.String

맀μž₯ ν…Œμ΄λΈ” μ˜ˆμ•½ μ„œλΉ„μŠ€λ₯Ό κ΅¬ν˜„ 쀑 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.
ν•΄λ‹Ή μ—λŸ¬μ— λŒ€ν•΄ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€.


μ—λŸ¬λ‘œκ·Έ

org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.String
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:362) ~[spring-orm-5.3.27.jar:5.3.27]
	at com.sun.proxy.$Proxy113.merge(Unknown Source) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:315) ~[spring-orm-5.3.27.jar:5.3.27]
	at com.sun.proxy.$Proxy113.merge(Unknown Source) ~[na:na]
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:669) ~[spring-data-jpa-2.7.12.jar:2.7.12]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:289) ~[spring-data-commons-2.7.12.jar:2.7.12]
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137) ~[spring-data-commons-2.7.12.jar:2.7.12]
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121) ~[spring-data-commons-2.7.12.jar:2.7.12]
	at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:530) ~[spring-data-commons-2.7.12.jar:2.7.12]
    
...


뢄석

hibernate.id.IdentifierGenerationException, 즉 hibernate의 id κ΄€λ ¨ν•΄μ„œ μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.
java.lang.String κ΄€λ ¨ν•΄μ„œ μ—λŸ¬κ°€ λ°œμƒν–ˆλ‹€λŠ” 것은 Generation 값을 String 으둜 μž‘μ„±ν–ˆκΈ° λ•Œλ¬Έμ— λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
public class Member extends BaseEntity {

    @Id
    @GeneratedValue
    private String id;
    private String email;
    private String phone;
    private String nickname;
    private String password;

    @Enumerated(EnumType.STRING)
    private MemberStatus memberStatus;
    @Enumerated(EnumType.STRING)
    private MemberType memberType;

    private LocalDateTime registeredAt;
    private LocalDateTime unRegisteredAt;

}

idλŠ” userId둜 μž‘μ„±ν–ˆμ§€λ§Œ @GeneratedValue μ–΄λ…Έν…Œμ΄μ…˜μ„ μž‘μ„±ν•΄μ„œ λ°œμƒν•œ 였λ₯˜μ˜€μŠ΅λ‹ˆλ‹€.


ν•œ 번 μž‘μ„±ν•  λ•Œ μ§‘μ€‘ν•˜μž!(자꾸 이러면 속상해..)

profile
기둝을 μŠ΅κ΄€μœΌλ‘œ

0개의 λŒ“κΈ€