-->
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.  [ 4 posts ] 
Author Message
 Post subject: Criteria for "on delete cascade" ddl generation
PostPosted: Sun Oct 18, 2009 8:34 am 
Newbie

Joined: Sun Oct 18, 2009 8:27 am
Posts: 3
Hi

I have a problem with hbm2ddl.

For the mapping
Code:
   @ManyToOne(fetch = FetchType.LAZY, optional = false)
   @OnDelete(action = OnDeleteAction.CASCADE)
   public Planet getPlanetFrom() {
      return this.planetFrom;
   }
the corresponding ddl is what i expect, ie
Code:
    alter table public.Fleet_log
        add constraint FKEF7398B38FDF8617
        foreign key (planetFrom_id)
        references public.Planet
        on delete cascade;

But on the mapping
Code:
   @ManyToOne(fetch = FetchType.LAZY, optional = false)
   @OnDelete(action = OnDeleteAction.CASCADE)
   public Player getPlayerFrom() {
      return this.playerFrom;
   }
the generated ddl is
Code:
    alter table public.Fleet_log
        add constraint FKEF7398B33F4531F7
        foreign key (playerFrom_id)
        references public.Player;
The "on delete cascade" is not generated in this case, although the same mapping.

So, what is the (hidden) criteria for hbm2ddl for "on delete cascade" generation?
Thanks in advance


Top
 Profile  
 
 Post subject: Re: Criteria for "on delete cascade" ddl generation
PostPosted: Thu Oct 22, 2009 5:32 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
What a dialect do you use.
Most likely your implementation of Dialect#supportsCascadeDelete() returns false.


Top
 Profile  
 
 Post subject: Re: Criteria for "on delete cascade" ddl generation
PostPosted: Thu Oct 22, 2009 1:14 pm 
Newbie

Joined: Sun Oct 18, 2009 8:27 am
Posts: 3
I use PostgresqlDialect.
And if supportsCascadeDelete really return false or true, i must have all or no cascade, not cascade in some cases and no cascade on other cases :'(


Top
 Profile  
 
 Post subject: Re: Criteria for "on delete cascade" ddl generation
PostPosted: Thu Oct 29, 2009 4:13 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Look for differences of Player and Planet entities mappings.


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

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.