我一直在嘗試在我的 spring 應用程式中創建一個繼承其他類內容的物體。我希望繼承類的欄位保留在資料庫中,但一切都是徒勞的。我也在使用龍目島。我在這里做錯了嗎?
兒童班:
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDetails extends Users{
@Id
Long uId;
String description;
String postalAddress;
Long postalCode;
}
父類:
public class Users {
Long userId;
String username;
String email;
String password;
}
uj5u.com熱心網友回復:
類用戶也將是一個物體,但它沒有用相同的“@Entity”注釋。此外,您可能必須為父類提供 @Inheritance 注釋。
參考 - https://blog.netgloo.com/2014/12/18/handling-entities-inheritance-with-spring-data-jpa/
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/485082.html
