Hibernate“无法获取下一个序列值”甲骨文
当我尝试使用 Hibernate 保存此实体时,出现此错误无法获取下一个序列值
:
package beans;
import javax.persistence.*;
@Entity
@Table(schema = "EVGENY")
public class Article {
@SequenceGenerator(name="ArticleGen", sequenceName="ARTICLESEC")
@Id
@GeneratedValue(generator= "ArticleGen")
private int id;
@Column(name="title")
private String title;
@Column(name="text")
private String text;
@Column(name="postat")
private String postat;
@ManyToOne
@JoinColumn(name = "USER_ID")
private UserAcc user;
public Article(){
}
Get Set...
}
insert into article (title) values('asdfaf');
在 Oracle SQL Developer 中,插入文章(标题)值('asdfaf'); 效果很好。
如果我显式设置 id 变量( Article a = new Article();a.setId(3);
) 一切都好。我仔细检查了序列的名称。
i get this error could not get next sequence value
when I try to save this Entity with Hibernate:
package beans;
import javax.persistence.*;
@Entity
@Table(schema = "EVGENY")
public class Article {
@SequenceGenerator(name="ArticleGen", sequenceName="ARTICLESEC")
@Id
@GeneratedValue(generator= "ArticleGen")
private int id;
@Column(name="title")
private String title;
@Column(name="text")
private String text;
@Column(name="postat")
private String postat;
@ManyToOne
@JoinColumn(name = "USER_ID")
private UserAcc user;
public Article(){
}
Get Set...
}
insert into article (title) values('asdfaf');
in Oracle SQL Developer this insert into article (title) values('asdfaf');
works well.
if i set id variable explicitly ( Article a = new Article();a.setId(3);
)
everything is OK. I double checked the name of the sequence.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查用户对序列的权限。大多数时候都是拨款问题
Check user permissions on the sequence. Most of the time it is grant issue
我知道有很多导致这个例外的原因。也许您可以检查问题并向我提供有关您的问题的更多详细信息:
I know a lot of reasons to get this exception. Maybe you can check the questions and give me some more details about your problem: