Last active
December 10, 2015 14:49
-
-
Save BillOTei/8c4308d458408aea9ea7 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 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