-->
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: Migration from 4.3.9 to 5.1.5 (Foreign key problem)
PostPosted: Mon Mar 20, 2017 5:21 am 
Newbie

Joined: Fri Mar 17, 2017 6:45 am
Posts: 3
in domain i have:

Code:
        @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
   @JoinColumn(name="AddrID", nullable = true, updatable = true)
   public Address getAddress() {
      return address;
   }


With Hibernate 4.3.9 it was creating foreign key with name FK_687us5fhb8bwavfrrwj97o0s7.
After migrating to Hibernate 5.1.5 it creates a duplicate foreign key with name FKdeto0y750974e303dkg4qlh1e.

What i need it to keep the old foreign key name (FK_687us5fhb8bwavfrrwj97o0s7).

I try Hibernate5NamingStrategy without any success, it does not call determineForeignKeyName or determineJoinColumnName methods.


Top
 Profile  
 
 Post subject: Re: Migration from 4.3.9 to 5.1.5 (Foreign key problem)
PostPosted: Mon Mar 20, 2017 6:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I think it's because of the HHH-11089 which is now fixed in 5.2.9. I don't know if it was backported to 5.1.5, or if it will ever be since Gail decides what needs to be backported.

Try it with 5.2.9, and see if it works, and then add a comment on the issue to mention that it's important for you to have it backported to 5.1.x.


Top
 Profile  
 
 Post subject: Re: Migration from 4.3.9 to 5.1.5 (Foreign key problem)
PostPosted: Mon Mar 20, 2017 8:38 am 
Newbie

Joined: Fri Mar 17, 2017 6:45 am
Posts: 3
I try with version 5.2.9, but it does not solve my problem.

My problem is the following:
We have more then 100 domains where foreign key name is not defined explicitly. Hibernate generate it automatically.

We need to have hibernate.hbm2ddl.auto=update due to some requirements.

After migrating to Hibernate 5.x, it generate duplicate foreign keys because naming has been changed.

So, now i need somehow to re-implement foreign key naming strategy, in order to use the one used with Hibernate 4.3.9.

I try to re-implement PhysicalNamingStrategy and ImplicitNamingStrategy, but without any success.

How it generate foreign key names?
Shouldn't it call determineForeignKeyName?


Top
 Profile  
 
 Post subject: Re: Migration from 4.3.9 to 5.1.5 (Foreign key problem)
PostPosted: Mon Mar 20, 2017 9:43 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Try setting the hibernate.implicit_naming_strategy configuration property to legacy-hbm.

Code:
<property name ="hibernate.implicit_naming_strategy" value="legacy-hbm"/>


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.