Skip to content

Instantly share code, notes, and snippets.

@tyama
Created December 25, 2009 04:47
Show Gist options
  • Save tyama/263511 to your computer and use it in GitHub Desktop.
Save tyama/263511 to your computer and use it in GitHub Desktop.
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')}"
}
}
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