[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2155) mysql dialect should not generate automatically index for foreign key

Anthony Patricio (JIRA) noreply at atlassian.com
Tue Oct 17 08:00:25 EDT 2006


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
        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:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list