Home > OS >  Error While Creating Entities in Spring boot application
Error While Creating Entities in Spring boot application

Time:06-02

I have been trying to create an entity in my spring application that inherits the contents of other class. I wanted the fields of the inherited class to persist in the database but all in vain. I am using Lombok as well. Am I doing something wrong here?

Child class:

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor

public class UserDetails extends Users{

@Id
Long uId;

String description;

String postalAddress;

Long postalCode;

}

Parent class:

public class Users {

Long userId;

String username;

String email;

String password;


 }

CodePudding user response:

Class users will also be an entity but it was not annotated with the same "@Entity". Also you might have to provide the @Inheritance annotation for the parent class.

Reference - https://blog.netgloo.com/2014/12/18/handling-entities-inheritance-with-spring-data-jpa/

  • Related