| Hello
I have a problem with my OneToOne relationship., which always results in two selects.
This is my query: select up from UserProfile up where up.profileCode = :profileCode
This is my (simplified) UserProfile Class:
public class UserProfile extends BaseEntity {
@Column(name = "PROFILE_CODE", nullable = false, unique=true) private String profileCode;
@OneToOne(fetch=FetchType.LAZY, optional=false) @JoinColumn(name="USER_ID", unique=true, nullable=false) private User user = new User(); }
These are the SQL Queries:
SELECT ID, PROFILE_CODE, USER_ID FROM USER_PROFILES WHERE (PROFILE_CODE = ?) SELECT ID, EMAIL, GENDER, INITIALS, LAST_NAME, PHONE_NUMBER, SIGNUP_DATE, CITY, HOUSE_NUMBER, POSTCODE, STREET FROM USERS WHERE (ID = ?)
No matter what I do (FetchType.Lazy, optional=false etc), Eclipselink always generates 2 selects. What I want is just one select for the UserProfile with the profileCode!
Can somebody explain to me why there is always an additional select for the user object?
Thank you! Leon
|