-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: One-to-One key associations
PostPosted: Mon Sep 24, 2007 12:54 pm 
Newbie

Joined: Mon Sep 24, 2007 10:45 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.