Created
December 25, 2009 04:47
-
-
Save tyama/263511 to your computer and use it in GitHub Desktop.
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
package jp.grails | |
import javax.persistence.* | |
import org.datanucleus.jpa.annotations.Extension | |
//import org.hibernate.annotations.* | |
@Entity | |
class Comment implements Serializable { | |
static belongsTo = [todo:Todo] | |
@Id | |
//@GeneratedValue(generator="system-uuid") | |
//@GenericGenerator(name="system-uuid",strategy = "uuid") | |
@GeneratedValue(strategy=GenerationType.IDENTITY) | |
@Extension (vendorName = "datanucleus",key = "gae.encoded-pk", value = "true") | |
String id | |
@Column | |
String message | |
@Column | |
String user | |
@Column | |
Date dateCreated = new Date() | |
@ManyToOne | |
Todo todo | |
static constraints = { | |
todo() | |
dateCreated display:false | |
message() | |
user() | |
dateCreated() | |
} | |
String toString(){ | |
"$message by $user ${dateCreated.format('yyyy/MM/dd HH:mm:ss')}" | |
} | |
} |
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
package jp.grails | |
import javax.persistence.* | |
import org.datanucleus.jpa.annotations.Extension | |
//import org.hibernate.annotations.* | |
@Entity | |
class Todo implements Serializable{ | |
static hasMany = [comments:Comment] | |
@Id | |
//@GeneratedValue(generator="system-uuid") | |
//@GenericGenerator(name="system-uuid",strategy = "uuid") | |
@GeneratedValue(strategy=GenerationType.IDENTITY) | |
@Extension (vendorName = "datanucleus",key = "gae.encoded-pk", value = "true") | |
String id | |
@Column | |
String content | |
@Column | |
String user | |
@Column | |
Date due | |
@OneToMany(mappedBy="todo") | |
List<Comment> comments | |
static constraints = { | |
content() | |
user() | |
due() | |
} | |
String toString(){ | |
content | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment