0
我目前使用: - 斯卡拉2.10 - Squeryl v 0.9.6 - MySQL連接v5.1.28問題與Squeryl @Column批註有Play框架和MySQL
I'have我的定義這樣的模型類:
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 DB中列名稱中的連字符](http://stackoverflow.com/questions/885497/hyphens-in-column-names-in-mysql-db)。 – t0mppa
我已經使用back-ticks沒有成功:\ –