Hello!
I have many-to-one relationship between Answer and Topic. My Answer looks as :
Code:
@Entity
@Table(name = DataBaseConstants.ANSWER_TABLE, catalog = DataBaseConstants.DBCATALOG, schema = "")
@XmlRootElement
@Access(AccessType.PROPERTY)
public class Answer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = DataBaseConstants.ANSWER_ID, nullable = false, updatable = false, insertable = false)
public Long getAnswer_id() {
return answer_id;
}
@Version
@Column(name = "OPTLOCK")
public Long getVersion() {
return version;
}
@Size(max = 21000)
@Column(name = "content", columnDefinition = "VARCHAR")
public String getContent() {
return content;
}
@NotNull(message = "{Post_rate_notnull}")
@Column(name = "rate")
public Integer getRate() {
return rate;
}
@NotNull(message = "{Post_date_notnull}")
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "[PUBLISH_DATE]")
public Date getPublish_date() {
return publish_date;
}
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "topic", referencedColumnName = "topic_id", nullable = false)
public Topic getTopic() {
return topic;
}
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user", referencedColumnName = "user_id")
@NotFound(action = NotFoundAction.IGNORE)
public JuniorUser getUser() {
return user;
}
Answer has hashcode and equals based on answer_id. There is no toString().
The problem is when I call method load() to get hibernate proxy of Answer , it loads immediately all Answer's and Topic's and JuniorUser's properties.
Code:
currentSession().load(Answer.class,1);
What causes hibernate to load everything immediately?
BTW, I set breakpoint just after this method is called and see all queries generated by hibernate in my console.
Thanks!