【发布时间】:2012-02-20 14:24:20
【问题描述】:
我正在使用 Hibernate,并且有一个名为“User”的持久类。由于这是一个关键字,我用不同的名称标记了@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,我添加了导致我相信它仍在使用列名的错误。
标签: java hibernate postgresql jpa