开发者

Possible to query a database with subclass entity

开发者 https://www.devze.com 2023-03-24 16:19 出处:网络
Ok, lets say I have a model. @Entity public class Person extends Model开发者_开发技巧 { public String name;

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?

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.


Look up the @PostLoad annotation, which you can use to initialize any transient variables.

0

精彩评论

暂无评论...
验证码 换一张
取 消