1

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; } 

1 Answer 1

2

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/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.