Hi! I have a doubt about how to retrieve an @embeddable collection of elements with a Named Query. Let me illustrate it with an example:
Let's suposse that I have a Customer Entity which can have different addresses, forming a relation one-to-many like this:
Code:
@Entity
@Table(name="CUSTOMERS")
public class Customer implements ICustomer{
.. id and other columns...
@org.hibernate.annotations.CollectionOfElements(fetch=FetchType.LAZY, targetElement=Address.class)
@JoinTable(
name = "ADDRESSES",
joinColumns = @JoinColumn(name = "customer_id")
)
private List<IAddress> addressses= new ArrayList<IAddress>();
}
Code:
@Embeddable
public class Address implements IAddress{
... columns...
}
Adress isn't an entity, it's an embeddable class and therefore cannot be queried with an Named Query, Am I right?
How would you type etrieve, for example, all addresses? Would you use a "native" sql query?