I am curious whether I can write something like this in JPA?
Or, Hibernate has such extension?
Or, @PostLoad has such equivalent?
Or, we must write separate DAO/Repository/Service?
@Entity
class Foo {
@Id
long id;
@Basic
String name;
@Transit
// Query("select address from Address a where a.username = this.name + '000' "
String address;
}
Even more
@Entity
class Bar {
@Id
long id;
@Basic
String code;
@Basic
String name;
@Transit
// Query("select name from Bar b where b.code = substr(this.code, 0, 2) + '0000' "
String provinceName;
@Transit
// Query("select name from Bar b where b.code = substr(this.code, 0, 4) + '00' "
String cityName;
}