If I have two hibernate entities like:
@Entity
class Company {
@Id
Integer id;
String name;
}
@Entity
class Person {
Integer id;
St
Yes, you can do it.
Does it save just the reference, or also update the company with name=null?
With default cascade
, like that, Hibernate will do nothing. So answer is: It saves just a foreign key.
The most valid (for JPA too) approach is using session.load(Company.class, 1)
. It returns a proxy without do any request to the database. But, you need to have a session for it, of course.