Hello @,
we have db bottleneck after migration from Hibernate to JPA (3.2.5.ga
and Jboss 4.0.5 GA)
Scenario:
Code:
@Entity
class Order {
@Id @GeneratedValue
private long;
@ManyToOne
@JoinColumn(name = "ADDRESSID")
private Address address;
}
@Entity
class Address {
@Id @GeneratedValue
private long;
}
When Order instance is loaded using em.find than 2 select's are executed:
select * from Order
select * from Address where id = ? // order.addressid
The same is done when I have query which returns X orders (select on Adrress table is executed only one per address instance, e.g. order1 and order2 references same addressA object than only one select is executed to retrieve the addressA)
The same behaviour is in bidirectional scenario.
In original pure hibernate code join is executed immediately. The order's hbm file contains
<many-to-one
name="address"
column="addressId"
class="Address"
cascade="all"
unique="false"/>
I tried also to use hibernate specific @Fetch(SELECT) - without success
I would also like to avoid db schema change unless really neccesary
Thanks for any hint