hi ,everyone
I am new to play2 and circumflex,and know i encounted a problem which boring me much.
this is my class with circumflex
class User extends Record[Long, User] with IdentityGenerator[Long, User] {
def this(username: String, password: String, status: Int, descn: String, id: Long) = {
this()
this.username := username.trim()
this.password := password
this.status := status
this.descn := descn
if (id == 0L) this.id.setNull else
this.id := id
}
// def this(username: String, password: String) = {
// this()
// this.username := username.trim()
// this.password := password
// }
def relation = User
def PRIMARY_KEY = id
val descn = "descn".VARCHAR(200)
val username = "username".VARCHAR(50).NOT_NULL
val id = "id".BIGINT.NOT_NULL.AUTO_INCREMENT
val password = "password".VARCHAR(50).NOT_NULL
val status = "status".INTEGER
}
and this is my object
object User extends User with Table[Long, User] {
override def isAutoRefresh: Boolean = true
// def apply(username: String, password: String):User =this(username,password)
def apply(username: String, password: String, status: Int, descn: String, id: Long):User=new User(username, password, status, descn,0L)
private val userDbObj = this AS "userDbObj"
def critStand = userDbObj.criteria
validation.notEmpty(_.username)
def findUserByName(name: String): Seq[User] =
(this AS "u").map(u => SELECT(u.*).FROM(u).WHERE(u.username EQ name).list)
def findUser(): Seq[User] =
(this AS "u").map(u => SELECT(u.*).FROM(u).WHERE(u.username IS_NOT_NULL).list)
def findById(id: Long): Option[User] = {
(this AS "u").map(u => SELECT(u.*)
.FROM(u)
.WHERE((
u.id EQ id))
.unique)
}
def update(u: User) = {
println(u.username())
println(u.UPDATE(
u.id, u.username, u.descn, u.status, u.password))
}
def save(u: User): String = {
println(u.username())
println(u.save())
// COMMIT()
u.refresh()
""
}
}
when I excute save and update ,the value u.save() returns 1,same to update method,I wonder why it can't work with a COMMIT() which have annote it,and I find this is Google,I can't find a result at it
could someone can help me ?