开发者

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?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜