-->
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: Hibernate 4.3 to 5 Foreign Key Name Change
PostPosted: Fri Oct 30, 2015 6:49 pm 
Newbie

Joined: Wed Jan 27, 2010 12:45 am
Posts: 9
I'm starting a migration from Wildfly 8.1 to Wildfly 10 which is a hibernate jump from 4.3 to 5.0

Everything seems to be working smoothly except that the hbm2ddl update that occurs on the first deployment is creating all new foreign keys on my @ManyToOne associations

For example an existing FK exists what was created by Hibernate 4 with the name FK281588E9730950D2. Hibernate 5 is leaving the old one in place, but creating a duplicate with a name of FKbxtm5y7q7jul8or4g1gmkpa6v

hibernate.hbm2ddl.auto is update

Is this expected? Is there a config option that I'm missing to preserve a previous naming strategy?


Top
 Profile  
 
 Post subject: Re: Hibernate 4.3 to 5 Foreign Key Name Change
PostPosted: Sun Nov 01, 2015 3:44 pm 
Newbie

Joined: Sun Nov 01, 2015 3:34 pm
Posts: 1
In addition to the automatically-generated foreign key name change, I found that Hibernate 5 is not honouring the foreign-key attribute specified in '<key>' element, i.e: I have this:

Code:
    <set name="roles" lazy="false" table="consumer_roles">
     <key column="consumer" foreign-key="FKConsumerRolesConsumer"/>
     <many-to-many column="role" class="org.jpos.ee.Role" foreign-key="FKConsumerRolesRole"/>
    </set>


In 4.3.11.Final I get:

Code:
    alter table consumer_roles
        add constraint FKConsumerRolesRole
        foreign key (role)
        references role;

    alter table consumer_roles
        add constraint FKConsumerRolesConsumer
        foreign key (consumer)
        references consumer;


same config with 5.0.2.Final gives:

Code:
alter table consumer_roles add constraint FK48dmxni8c7c85pvwgooneoy92 foreign key (role) references role;
alter table consumer_roles add constraint FKtr3o7se0v5nhgy29tosm9a6ek foreign key (consumer) references consumer;


I'm sure it has to be something wrong on my side, but didn't manage to figure out what just yet.


Top
 Profile  
 
 Post subject: Re: Hibernate 4.3 to 5 Foreign Key Name Change
PostPosted: Mon Nov 02, 2015 1:25 pm 
Hibernate Team
Hibernate Team

Joined: Sun Jul 17, 2011 9:28 am
Posts: 4
it seems related to https://hibernate.atlassian.net/browse/HHH-10247


Top
 Profile  
 
 Post subject: Re: Hibernate 4.3 to 5 Foreign Key Name Change
PostPosted: Mon Nov 02, 2015 1:37 pm 
Newbie

Joined: Wed Jan 27, 2010 12:45 am
Posts: 9
dreab8 wrote:
it seems related to https://hibernate.atlassian.net/browse/HHH-10247


Yes it may be related. In my case I am not statically specifying any FK names and it is creating a whole new set of auto generated ones alongside my previously auto generated ones.

Comparing the start-up from 4.3.6.Final it just appears that it isn't recognizing that any FKs exist for those ManyToOne Associations.


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.