Caused by: java.lang.IllegalArgumentException: Not a managed type: class…
- User
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.dbs.dtip.hsm.entity.AddressMapping
- Assistant
The exception:
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.dbs.dtip.hsm.entity.AddressMappingindicates that the JPA EntityManager or Spring Data JPA repository is trying to manage a class that is not recognized as a JPA entity.
Common causes and how to fix them:
- User
package com.dbs.dtip.hsm.entity;
import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor;
import javax.persistence.*; import java.sql.Timestamp;
@Entity @Table(name = "hsm_address_mapping") @Builder @Data @NoArgsConstructor @AllArgsConstructor public class AddressMapping { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String keyLabel; private String publicKey; private String address; private Timestamp createDt; private Timestamp updateDt; }
I am using Spring boot 3.5
- Assistant
Thanks for sharing your entity! Your class is properly annotated as a JPA entity:
- User
Does it matter I use import javax.persistence.; or import jarkarta.persistence.; here?
- Assistant
- User
But when I change to jakarta.persistance, I encounter this org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: EntityManagerFactory interface [interface org.hibernate.SessionFactory] seems to conflict with Spring's EntityManagerFactoryInfo mixin - consider resetting the 'entityManagerFactoryInterface' property to plain [jakarta.persistence.EntityManagerFactory]
- Assistant
- User
How do I know If I am using correct hibernate?
- Assistant
- User
[INFO] | +- org.hibernate.orm:hibernate-core:jar:6.6.15.Final:compile (version managed from 6.6.15.Final)
- Assistant
Your dependency tree shows:
org.hibernate.orm:hibernate-core:jar:6.6.15.Final:compileThis means:
- You are using Hibernate 6.6.15.Final, which is the latest Hibernate 6.x version.
- This version fully supports
jakarta.persistence.*APIs and is compatible with Spring Boot 3.x.
What does this mean for you?
- Your Hibernate version is and up-to-date.
- User
- Assistant