- SELECT a, b, a+b FROM uninteresting_table;
In JPA-land, I started by writing my own fetch query and added a dummy field to the database table to accomplish this. Class, let's say this together, "This sucks.". However, I did perform a little bit of JPA trickery to get what I want, with the custom fetch query and no dummy data field. In your persistent bean you'll simply annotate your column as follows:
- // Java code above....
- @Column(name="a+b", insertable=false, updatable=false)
- Long myNewColumn;
- //Java code below....
In the example above, you'll see I just injected my sql I want as that column name and the rest JPA handles for you. Other examples include:
1 comment:
This article was very useful for us! Thank you very much!
Olga
Post a Comment