Created
April 13, 2014 00:12
-
-
Save yuki-takei/10563186 to your computer and use it in GitHub Desktop.
MongoDB GORM - Inheritance mapping Tips ref: http://qiita.com/yuki-takei/items/2b173dea5c45de44fcb8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class AbstractUser { | |
static mapWith = "mongo" | |
static mapping = { | |
name index: true | |
} | |
static constraints = { | |
desc nullable: true | |
} | |
String name | |
String desc | |
def beforeInsert() { | |
doSomething() | |
} | |
def afterLoad() { | |
doSomething() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveUser extends User { | |
static mapping = { | |
collection "activeUser" // 無視される | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"_class": "ActiveUser", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"_class": "ActiveUser", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InactiveUser extends User { | |
static mapping = { | |
collection "inactiveUser" // 無視される | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User { | |
static mapWith = "mongo" | |
static mapping = { | |
collection "user" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment