Created
February 17, 2011 20:56
-
-
Save jbjonesjr/832669 to your computer and use it in GitHub Desktop.
3-tier gorm ball of fail
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
/* | |
This is a bit of a contrived example, but attempts to show the level and relationships of data that I am working with. | |
Three-tiered snippet example. Logic: | |
A person has an office full of file cabinets and folders. They own these items. | |
Any Person has a zero to many of these Cabinets and Folders. There are also default's specified for ease of access when dealing with a person's possessions. | |
A FileCabinet of course has a group of folders that are available under it, and it is as well tied to a Person. If the Person were to be deleted(morbid), then the FileCabinet would as well. | |
A Folder has a bunch of properties, including it's parent File Cabinet and Owner. | |
*/ | |
/* | |
* Right off the bat I could probably move the default properties to the sub items, but have it at the Person level for ease of access and updating. Also important to note is that 2 people (Person's) may both share a folder, but only 1 stores it as a default. that was my logic for having the default belong to a person not a folder/cabinet. | |
* | |
*/ | |
class Person{ | |
FileCabinet defaultFileCabinet; | |
Folder defaultFolder; | |
static hasMany = [folders: Folder , fileCabinets: FileCabinet ] | |
} | |
class FileCabinet { | |
static hasMany = [folders: Folder] | |
static belongsTo = [owner: Person] | |
} | |
class Folder{ | |
FileCabinet fileCabinet; | |
Person owner; | |
String name; | |
int DocumentCount; | |
.... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment