I configured a simple OneToOne mapping in my entity, but when I persist the object I see a "Select" statement being executed by Hibernate just before the Insert and I don't know why.
@Entity
@Table( name = "USER" )
public class NewUser {
@OneToOne
@JoinColumn(name="user_status_type_id", nullable=false)
private UserStatusType userStatusType;
UserStatusType is just a read-only lookup table, so nothing persists in that table when I save User.
User u = new User();
u.setUserStatusType( new UserStatusType(101));
session.persis(u);
But when I persist the User object, the output from Hibernate reads as follows:
Hibernate: select userstatus_.user_status_type_id, userstatus_.user_status_name as user2_3_ from USER_STATUS_TYPE userstatus_ where userstatus_.user_status_type_id=?
Hibernate: insert into USER (created, first_name, last_name, password, user_name, user_status_type_id) values (?, ?, ?, ?, ?, ?)
I don't know if that's normal for Hibernate. I figured since it was a "persist" operation I would only see an Insert statement; not sure of the purpose for the Select.
Is the mapping incorrect?