I used the annotation suggestion from this article:
How to use existing Oracle sequence to generate id in hibernate?
@GenericGenerator(name = "announcementGenerator", strategy = "sequence-identity",
parameters = @org.hibernate.annotations.Parameter(name = "sequence", value = "ANNOUNCEMENT_ID_SEQ"))
@Id
@GeneratedValue(generator = "announcementGenerator")
@Column(name="ANNOUNCEMENT_ID")
But I still get the error in the title. The generated sql from hibernate seems to include
next value for ANNOUNCEMENT_ID_SEQ
Instead of the traditional
ANNOUNCEMENT_ID_SEQ.nextval
I've also used the suggestion in this article: ORA-00917: missing comma error while using custom oracle sequence in hiberanate
And it put a null in the place of the primary key... which makes sense with the annotation given in that article.
Am I missing something? Any assistance would be appreciated. Thanks in advance!
From Hibernate doc about sequence-identity
This strategy is only supported on Oracle 10g drivers targeted for JDK 1.4.
If you aren't using 10g set strategy = "sequence"
or "native"
can solve the problem.
Else use
@GeneratedValue(strategy=GenerationType.AUTO, generator="announcementGenerator")
@SequenceGenerator(name="announcementGenerator", sequenceName="ANNOUNCEMENT_ID_SEQ")
Hope can help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.