@Column注释在Squeryl中带有游戏框架和MySQL的问题



我当前正在使用:-Scala v2.10 - Squeryl v 0.9.6-MySQL连接器v5.1.28

我已经定义了我的模型类:

class identities (
    val user_id: Long,
    val changed: String,
    val del : Long,
    val standard : Long,
    val name : String,
    val organization : String,
    val email : String,
    @Column("reply-to")
    val reply_to : String,
    val bcc: String,
    val signature: Option[String],
    val html_signature : Long,
    val pass : Option[String]) extends KeyedEntity[Long]
 {
    var identity_id : Long = 0
    def id = identity_id
 }

但是,每当我尝试使用squeryl方法上选择所有查询时,我会收到此错误:

> [RuntimeException: Exception while executing statement : You have an
> error in your SQL syntax; check the manual that corresponds to your
> MySQL server version for the right syntax to use near 'to as
> identities14_reply-to, identities14.signature as
> identities14_signature,' at line 9 errorCode: 1064, sqlState: 42000
> Select identities14.del as identities14_del, identities14.organization
> as identities14_organization, identities14.name as identities14_name,
> identities14.email as identities14_email, identities14.standard as
> identities14_standard, identities14.html_signature as
> identities14_html_signature, identities14.identity_id as
> identities14_identity_id, identities14.reply-to as
> identities14_reply-to, identities14.signature as
> identities14_signature, identities14.changed as identities14_changed,
> identities14.user_id as identities14_user_id, identities14.bcc as
> identities14_bcc, identities14.pass as identities14_pass From
> identities identities14 jdbcParams:[]]

绝对绑定到注释:@Column("reply-to"),因为通过修改列的名称,错误消失了,并且查询是正常执行的。不幸的是,更改列的名称不是我的选择,所以我问您帮助找到更好的解决方案。

您肯定需要引用您的列,您可以做两件事:

默认情况下在MySQL适配器进行启用时可以引用:

new MySQLAdapter {
     def quoteIdentifier(field: String) = "`"+field+"`"
}

或者您可以更改关系列场中的列名

object Schema1 extends Schema {
  on(identities)(p => declare(
    table1.reply_to is(named("myreplyto"))
  )
}

最新更新