I have a JPA object called Customer.java:
@NamedQueries({@NamedQuery(name="getAccountWithCheckRangeByService",
query="SELECT c FROM Customer"})
public Long Id;
public Address address;
//getter and setter
}
Now, if I invoke the named query and load the Custoemr object. and then if I do c.getAddress(), will I get the Address loaded? Or do i need to write a separate named query to load the address
You probably mean
SELECT c FROM Customer c.If you want to ensure that the address is loaded you can use fetch joins.
SELECT c FROM Customer c JOIN FETCH c.address