Hi,

I'm just wondering how JBoss handles foreign key constraints. I have an entity 
with a OneToOne-Mapping and CascaseType.ALL set, but in the database schema no 
cascade delete is set.

Here's a code fragement:


  | @Entity
  | @Table(name = "Users")
  | public class User implements Serializable {
  |     private int id;
  | 
  |     private ChatInfo chatInfo;
  | 
  |     @OneToOne(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER, 
optional = false)
  |     public ChatInfo getChatInfo() {
  |         return chatInfo;
  |     }
  | 
  |     public void setChatInfo(ChatInfo chatInfo) {
  |         this.chatInfo = chatInfo;
  |     }
  | }
  | 
  | @Entity
  | @Table(name = "ChatInfo")
  | public class ChatInfo implements Serializable {
  |     private int id;
  | 
  |     @Id
  |     @GeneratedValue(strategy = GenerationType.IDENTITY)
  |     @JoinColumn(name = "id", referencedColumnName = "chatinfo_id", table = 
"users", updatable = false, nullable = false)
  |     public int getId() {
  |         return id;
  |     }
  | 
  |     protected void setId(int id) {
  |         this.id = id;
  |     }
  | 
  | }
  | 

When I look on the database schema there I see "ON DELETE NO ACTION" at the 
foreign key constraint, but I had expected "ON DELETE CASCADE". Can anybode 
explain this?


  | CREATE TABLE users
  | (
  |   id int4 NOT NULL DEFAULT nextval('users_id_seq'::regclass),
  |   chatinfo_id int4 NOT NULL,
  |   CONSTRAINT users_pkey PRIMARY KEY (id),
  |   CONSTRAINT fk4e39de8d7cb3bff FOREIGN KEY (chatinfo_id)
  |       REFERENCES chatinfo (id) MATCH SIMPLE
  |       ON UPDATE NO ACTION ON DELETE NO ACTION,
  | ) 
  | 

I use JBoss 4.0.5 and a Postgres 8.1 database.

Best regards,
Strunker

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029750#4029750

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029750
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to