Skip to content

Commit

Permalink
fix for GRAILS-5895 so that basic collections mapped with Map can be …
Browse files Browse the repository at this point in the history
…configured for the table name with join column
  • Loading branch information
basejump authored and graemerocher committed Feb 22, 2010
1 parent a802d17 commit 6eb380e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 5 additions & 7 deletions grails.tmproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>currentDocument</key>
Expand All @@ -13,8 +13,6 @@
<string>grails</string>
<key>regexFolderFilter</key>
<string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
<key>selected</key>
<true/>
<key>sourceDirectory</key>
<string></string>
</dict>
Expand All @@ -28,14 +26,14 @@
<key>caret</key>
<dict>
<key>column</key>
<integer>28</integer>
<integer>26</integer>
<key>line</key>
<integer>12</integer>
<integer>20</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>3</integer>
<integer>0</integer>
</dict>
</dict>
<key>openDocuments</key>
Expand All @@ -45,6 +43,6 @@
<key>showFileHierarchyDrawer</key>
<true/>
<key>windowFrame</key>
<string>{{298, 84}, {886, 587}}</string>
<string>{{211, 4}, {1709, 1174}}</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -949,17 +949,23 @@ private static void bindCollectionTable(GrailsDomainClassProperty property, Mapp
*/
private static String calculateTableForMany(GrailsDomainClassProperty property) {
String propertyColumnName = namingStrategy.propertyToColumnName(property.getName());
//add fix here
//fix for GRAILS-5895
PropertyConfig config = getPropertyConfig(property);
JoinTable jt = config != null ? config.getJoinTable() : null;
boolean hasJoinTableMapping = jt != null && jt.getName() != null;
String left = getTableName(property.getDomainClass());

if (Map.class.isAssignableFrom(property.getType())) {
String tablePrefix = getTableName(property.getDomainClass());
return tablePrefix + "_" + propertyColumnName;
if (hasJoinTableMapping) {
return jt.getName();
}
else {
return left + UNDERSCORE + propertyColumnName;
}

}
else {
PropertyConfig config = getPropertyConfig(property);
JoinTable jt = config != null ? config.getJoinTable() : null;
boolean hasJoinTableMapping = jt != null && jt.getName() != null;

String left = getTableName(property.getDomainClass());

if (property.isBasicCollectionType()) {
if (hasJoinTableMapping) {
Expand Down

0 comments on commit 6eb380e

Please sign in to comment.