A
is associated with B
in a one-on-one
relation, the purpose is to retrieve columns from both A
and B
. First implementation took advantage of Hibernate Entity and relevant APIs, and the relationship was established via criteriaBuilder
APIs. The problem was that the performance seemed suffered.
A proposed solution is to use a stored proc which basically a plain select a.*, b.* from A a join B b on ....
. On the hibernate part, it calls the SP like:
Query q = session.getNamedQuery("sp_name")
B
in A
is like:
class A{
@OneToOne(fetch = FetchType.LAZY)
private B b;
...
}
the execution seemed failed to load values of B
's properties.
So what did I miss? How can I make it work and at the same time, improve the performance?