Hi,
I have a problem when I save an object.
I have two tables with a foreign key associations like this:
Code:
table USER{
NAME primary key,
ADDRESS references to STREET in ADDRESS
}
and
Code:
table ADDRESS{
STREET primary key,
DESCRIPTION varchar(50)
}
I have mapped these tables by these java objects:
Code:
public class User{
...
@OneToOne
@JoinColumn(name="ADDRESS")
private Address tAddress = null;
...
}
and
Code:
public class Address{
...
@OneToOne(mappedBy="tAddress")
private User tUser = null;
...
}
I read the object Address and I want to remove him User. I do this:
Code:
Session s = HibernateSessionFactory.getSession();
Address a = s.read(Address.class, 1);
a.setUser(null);
s.saveOrUpdate(a);
s.flush();
s.close;
but the row in User table has not been removed and I want to delete it.
How can I make it?
Enrico