我正在使用Hibernate並擁有一個名爲「用戶」的持久類。由於這是一個關鍵詞,我打上了不同的名稱@Entity屬性(我所看到的,例如,這個問題: Unable to use table named "user" in postgresql hibernate)錯誤:在「用戶」處或附近出現語法錯誤
不過,我還是遇到了麻煩,因爲這個類擴展了另一個,它看起來Hibernate等仍在嘗試使用「用戶」作爲列名和獲得搞砸:
@Entity(name = "XonamiUser")
public class User extends PropertyContainer {
...
和
@MappedSuperclass
public abstract class PropertyContainer implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected long key;
/** tags */
@ElementCollection
protected Set<String> tags;
@ElementCollection
protected Set<String> searchList;
...
我的擴展PropertyContainer其他類似乎很好地工作。
這是一個在冬眠的錯誤?有沒有一些解決這個重構短路的方法?謝謝!
下面是我看到的錯誤(略清理):
WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42601
ERROR org.hibernate.util.JDBCExceptionReporter - Batch entry 0 insert into user_search_list (user, search_list) values ('1', 'bjorn') was aborted. Call getNextException to see the cause.
WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42601
ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: syntax error at or near "user"
Position: 31
@TJ,我添加了錯誤,導致我相信它仍在使用列名。 – 2012-01-27 16:02:59