]
pazkooda commented on HHH-2155:
-------------------------------
Citation from "Java Persistence with Hibernate" (Section 8.3.7):
"For example, did you know that indexes on foreign key columns can hurt performance
in some situations and therefore aren't automatically
generated by Hibernate? We recommend that DBAs get involved early and verify the
automatically generated DDL from Hibernate."
Please take care of this issue. If some one wants such feature it is very easy to apply
custom MySql dialect (i.e. she/he can simply copy current one ;) ). Default one should not
rather contain automatic index creation.
mysql dialect should not generate automatically index for foreign
key
---------------------------------------------------------------------
Key: HHH-2155
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2155
Project: Hibernate3
Issue Type: Improvement
Components: core
Environment: MySQL
Reporter: Anthony Patricio
Priority: Minor
Attachments: patch-mysqlDialect.txt
MySQLDialect.getAddForeignKeyConstraintString(String, String[], String, String[],
boolean) method is generating also index which is not wanted.
Here is the modified method:
public String getAddForeignKeyConstraintString(
String constraintName,
String[] foreignKey,
String referencedTable,
String[] primaryKey, boolean referencesPrimaryKey
) {
String cols = StringHelper.join(", ", foreignKey);
return new StringBuffer(30)
//.append(" add index ")
//.append(constraintName)
//.append(" (")
//.append(cols)
//.append("), add constraint ")
.append(" add constraint ")
.append(constraintName)
.append(" foreign key (")
.append(cols)
.append(") references ")
.append(referencedTable)
.append(" (")
.append( StringHelper.join(", ", primaryKey) )
.append(')')
.toString();
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: