java - Hibernate @AttributeOverride with @ColumnTransformer -


i'm studying hibernate/jpa , doing practice to. task map entity:

@entity public class item {     @id     @generatedvalue(strategy = generationtype.identity)     private long id;      @embedded     @attributeoverride(name = "priceinusd", column = @column(name = "start_price_in_uah"))     private price startprice;      @embedded     @attributeoverride(name = "priceinusd", column = @column(name = "end_price_in_uah"))     private price endprice; } 

and here embeddable class:

@embeddable public class price {     @column(name = "price_in_uah")     @org.hibernate.annotations.columntransformer(             read = "{dont_know_what_to_put_here} * 0.039",             write = "? / 0.039")     private int priceinusd; } 

in db store price in uah , in java code have in usd. understand bit stupid example, still...

the problem when use hibernate's @columntransformer have specify column name in read property (like "price_in_uah * 0.039"), because of @attributeoverride annotation, column name can change.

so, can put instead of {dont_know_what_to_put_here} label?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -