简体   繁体   中英

Error While Creating Entities in Spring boot application

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;


 }

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM