I'm attempting to use a sequence in a DBMS independent fashion. So far I've tested the following and it works fine with Oracle 9i. The sequence that I'm using is in a schema, so, what I'm doing right now, is prefixing the name of the sequence with the name of the schema followed by a ".". However, I'm wondering if there is a different way to specify the name of the schema similar to how you can specify it using an @Table for an @Entity. This way it will in theory work regardless of the DBMS. i.e. Hibernate will build the fully qualified name using the appropriate separator character.
Note, when I try something similar using Hibernate mapping files, Hibernate automatically uses the schema that I specified for the table/class that the id column appears in. I'm thinking this should be the behavior when using annotations as well?
Also, I'm wondering, what happens to the SequenceGenerator, if I use a different database that supports identity columns instead, for example MSSQL. Is it just ignored (since I'm using GeneratorType.AUTO)?
Hibernate version: hibernate-3.1alpha1, hibernate-annotations-3.1beta3, hibernate-entitymanager-3.1beta1
Mapping documents:
Code:
@Column(name="pk1")
@Id(generate=GeneratorType.AUTO,
generator="calendarItemSequenceGenerator")
@SequenceGenerator(name="calendarItemSequenceGenerator",
sequenceName="bb_bb60.calendar_seq")
public int getId() {
return id;
}