I've got two entities:
public class Rank{
Short value;
@ManyToOne(fetch=FetchType.LAZY)
Picture pic;
...
}
public class Picture{
String url;
Long rank; // sum of all ranks' values
}
Is there a way to load Picture
and rank
field by query SELECT SUM(value) from ranks where pic = ?
?