java - Mapping a Transient Property to an Alias - Spring JPA -


is possible in spring jpa map transient property of object alias so?

native query

select *, 1 liked user user_id = 123 // + logic determine if liked 

class

@entity public class user {      @id     private long userid;      @column(name = "displayname")     private string displayname;      @transient     private int liked; // not tied column  } 

i've tried implement liked returns 0 should 1 (and null if defined field object type)

any appreciated!

you should use @formula annotation field (see the example)

the @formula annotation provide sql snippet hibernate execute when fetches entity database. return value of sql snippet gets mapped read-only entity attribute.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -