joinTable
目的 Purpose
Customizes the join table used for undirectional one-to-many, many-to-many and primitive collection types.使用例 Examples
Basic collection type:class Book { static hasMany = [chapterPageCounts: Integer] static mapping = {
chapterPageCounts indexColumn: [name: "chapter_number", type: Integer],
joinTable: [column: "page_count"]}enum VehicleStatus { OFF, IDLING, ACCELERATING, DECELERATING }class Truck { static hasMany = [states: VehicleStatus] static mapping = {
states joinTable: [name: 'VEHICLE_STATUS_LOG',
key: 'TRUCK_ID', column: 'STATUS']
}
}class Book { String title static belongsTo = Author static hasMany = [authors: Author] static mapping = {
authors joinTable: [name: "mm_author_books", key: 'mm_book_id' ]
}
}class Author { String name static hasMany = [books: Book] static mapping = {
books joinTable: [name: "mm_author_books", key: 'mm_author_id']
}
}class Employee { static hasMany = [projects: Project] static mapping = {
projects joinTable: [name: 'EMP_PROJ',
column: 'PROJECT_ID',
key: 'EMPLOYEE_ID']
}
}class Project { }詳細 Description
Usage:
使用方法: association_name(joinTable:map)Usage:
association_name(joinTable:map)引数: Arguments:
name- The table namekey(optional) - The foreign keycolumn(optional) - The inverse column
joinTable argument.

