我用的spring2.0+hibernate
数据库用的sql server 2005 字段SID设置为主键 自增然后实体类对应的字段配置
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "SID", unique = true, nullable = false)
public Integer getSid() {
return this.sid;
}
public void setSid(Integer sid) {
this.sid = sid;
}插入数据成功 但是查看后台里面有 Dialect does not support identity key generation的错误
查找applicationContext.xml里有段
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>我在网上查了下资料 别人都是使用的hbm.xml方式配置的 但是我是用的实体类来做的
现在已经蒙了。不知道怎么解决了。请高人指点一下
数据库用的sql server 2005 字段SID设置为主键 自增然后实体类对应的字段配置
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "SID", unique = true, nullable = false)
public Integer getSid() {
return this.sid;
}
public void setSid(Integer sid) {
this.sid = sid;
}插入数据成功 但是查看后台里面有 Dialect does not support identity key generation的错误
查找applicationContext.xml里有段
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>我在网上查了下资料 别人都是使用的hbm.xml方式配置的 但是我是用的实体类来做的
现在已经蒙了。不知道怎么解决了。请高人指点一下
@GeneratedValue(strategy = IDENTITY)
修改成sequence
可hbm.xml方式配置也必不可少
2个配置文件干不一样的事
我改完后错误提示变成了
Hibernate: select hibernate_sequence.nextval from dual
2009-07-07 17:15:26,044 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 208, SQLState: S0002>
2009-07-07 17:15:26,044 ERROR [org.hibernate.util.JDBCExceptionReporter] - <对象名 'dual' 无效。>
我现在没有hbm.xml数据库操作也没问题呢。只是有个错误提示说自增长问题
是啊,数据库是sqlserver,怎么配置oracle??
如果想使用oracle而且没有制定sequece的名字,则hibernate使用默认的名字HIBERNATE_SEQUENCE
你必须创建名为HIBERNATE_SEQUENCE 的sequence