-->
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.  [ 2 posts ] 
Author Message
 Post subject: Automatically generating index when creating foreign key
PostPosted: Mon Jul 11, 2016 1:24 pm 
Newbie

Joined: Mon Jul 11, 2016 1:21 pm
Posts: 1
All,
It looks like the MySQL schema generation code generates an index whenever a foreign key is created in order to ensure that queries are reasonably fast. This is not, however, done for Microsoft SQL Server. I wanted to change this behavior.

I've scoured the source code and don't see any easy way to do this (modifying the SQL server dialect won't work because the procedure to override occurs doesn't actually provide the table for which the foreign constraint is being added.

Any suggestions?


Top
 Profile  
 
 Post subject: Re: Automatically generating index when creating foreign key
PostPosted: Tue Jul 12, 2016 2:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Hibernate does not create any index implicitly. It is the underlying database that might create the index for a foreign key. When using PostgreSQL and MySQL (InnoDB), the index is created automatically. Unfortunately, SQL Server does not create indexes automatically for foreign keys, so you have to do that explicitly.

Although JPA offers the @Index annotation, you are better off using a tool like Flyway to generate your schema.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.