Skip to content

Instantly share code, notes, and snippets.

@BillOTei
Last active December 10, 2015 14:49
Show Gist options
  • Save BillOTei/8c4308d458408aea9ea7 to your computer and use it in GitHub Desktop.
Save BillOTei/8c4308d458408aea9ea7 to your computer and use it in GitHub Desktop.
package models
import dao.Dao
import com.avaje.ebean.annotation.CreatedTimestamp
import com.avaje.ebean.annotation.UpdatedTimestamp
import play.data.validation.Constraints
import javax.persistence._
import java.sql.Timestamp
import scala.beans.BeanProperty
@Entity
class Post {
@Id
var id: Long = 0
@Constraints.Required
@Column(length = 100)
@BeanProperty
var title: String = null
@Constraints.Required
@Column(length = 2000)
@BeanProperty
var content: String = null
@CreatedTimestamp
var whenCreated: Timestamp = null
@UpdatedTimestamp
var whenUpdated: Timestamp = null
}
object Post extends Dao(classOf[Post]) {
def apply(title: String, content: String): Post = {
val post = new Post()
post.setTitle(title)
post.setContent(content)
post
}
def unapply(post: Post): Option[(String, String)] = Some((post.getTitle, post.getContent))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment