Hi, I'm set up a simple one-to-one association (using Hibernate-3.3.0GA) between to classes (using annotations) and I'm trying to specify lazy loading, however I see selects for the second table in my log output. Here's what I've got:
@Entity
@Table(name = "members")
class Member {
...
private Contact contact;
...
@Id
@Column(name = "member_id")
public long getId() {
return id;
}
...
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public Contact getContact() {
return contact;
}
}
@Entity
@Table(name = "contactinfo")
public class Contact {
...
@Id
@Column(name = "contactinfo_id")
public long getId() {
return id;
}
...
}
My test method accesses the Member object like this:
...
session.beginTransaction();
Member m = null;
m = (Member)session.load(Member.class, id);
session.getTransaction().commit();
...
When I run this, I see selects for 'members' as well as 'contactinfo' tables in my log output.
|