1 year ago

#174822

test-img

J.E.Y

two entities of One-on-One relationship and use Hibernate namedQuery API

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?

java

hibernate

stored-procedures

nhibernate-mapping

0 Answers

Your Answer

Accepted video resources