而不是为每个实体“手动”调用SQL函数,有没有办法将其结果映射到实体瞬态字段?
@XXXX(call function with param ?) private int calculatedValue;
谢谢
你应该能够使用Hibernate的@Formula注释:
@Formula
https://docs.jboss.org/hibernate/orm/5.1/javadocs/org/hibernate/annotations/Formula.html
https://thoughts-on-java.org/hibernate-tips-calculate-entity-attributes-formula/