我想找到一种简单的方法来访问 Liftweb 中 Mapped 元素的最大值,这是我实际执行的示例:
映射器部分
class MappedEntity extends LongKeyedMapper[MappedEntity] with IdPK {
def getSingleton = MappedEntity
object targetRaw extends MappedInt(this)
}
object MappedEntity extends MappedEntity with LongKeyedMetaMapper[MappedEntity]
搜索部分
val max = MappedEntity.findAllByInsecureSql(
"SELECT MAX (targetRaw) AS targetRaw FROM MappedEntity",
IHaveValidatedThisSQL("chris", "2011,11,14")
).head.targetRaw.get
假设我使用名为 MappedEntity 的 SQL 表时,我想max
包含 astring
或int
等于targetRaw
如果您有任何建议或任何问题,我将很乐意提供帮助。