[英]Possible to query a database with subclass entity
Ok, lets say I have a model. 好的,可以说我有一个模型。
@Entity
public class Person extends Model {
public String name;
public String email;
}
Now. 现在。 I have a couple of transient fields that don't exist in the database, but I need to access them. 我有几个数据库中不存在的临时字段,但是我需要访问它们。 Basically they are fields for displaying the Person on a web page. 基本上,它们是用于在网页上显示“人员”的字段。
@Entity
public class PersonDisplay extends Person {
@Transient
public String DT_RowClass = "";
@Transient
public String cellColor = "";
}
Is it possible to query the PersonDisplay and get the Person object plus the PersonDisplay default values? 是否可以查询PersonDisplay并获取Person对象以及PersonDisplay默认值?
Like this. 像这样。
PersonDisplay display = PersonDisplay.find("byEmail" , "test@test.com").first();
I'm running into a few errors when I do this. 执行此操作时,我遇到了一些错误。
Let me know if I need to explain this again. 让我知道是否需要再次解释。
查找@PostLoad
批注,可用于初始化任何临时变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.