[b]Hibernate version:3,2,1,GA
I'm trying to share a sequence between two tables, as EJB3.0 persistence api docs states:
Quote:
This annotation defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation. A sequence generator may be specified on the entity class or on the primary key field or property. The scope of the generator name is global to the persistence unit (across all generator types).
My First Entity has the following anotations
Code:
@Id
@Column(name = "id", unique = true, nullable = false, insertable = false, updatable = false)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="services_process_seq")
@SequenceGenerator(name="services_process_seq", sequenceName="services_process_id_seq")
private int id;
In My Second Entity I tried:
Code:
@Id
@Column(name = "id", unique = true, nullable = false, insertable = false, updatable = false)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="services_process_seq")
private int id;
Id doesn't work it gives:
Code:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.AnnotationException: Unknown Id.generator: services_process_seq
Then I tried
Code:
@Id
@Column(name = "id", unique = true, nullable = false, insertable = false, updatable = false)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="services_process_seq")
@SequenceGenerator(name="services_process_seq")
private int id;
It gives me this error,(because hibernate_sequence does no exist, of course this is correct I'm expecting to use serices_process_id_seq)
Code:
select
nextval ('hibernate_sequence')
ERROR: Could not create data: org.hibernate.exception.SQLGrammarException: could not get next sequence value
I've tried some more variants as writing de @SequenceGenerator at class level, not field/attribute, etc..., and all of them give me the same error.
Can anyone tell me if I'm expecting something that won't happen, I'm writing something wrong ?
Any help will be welcomed
Thanks in advance
tonio