Hibernate schema parameter doesn't work in @SequenceGenerator annotation
Posted
by tabdulin
on Stack Overflow
See other posts from Stack Overflow
or by tabdulin
Published on 2010-04-09T09:37:42Z
Indexed on
2010/04/09
9:43 UTC
Read the original article
Hit count: 353
I hav the following code:
@Entity
@Table(name = "my_table", schema = "my_schema")
@SequenceGenerator(name = "my_table_id_seq", sequenceName = "my_table_id_seq",
schema = "my_schema")
public class MyClass {
@Id
@GeneratedValue(generator = "my_table_id_seq",
strategy = GenerationType.SEQUENCE)
private int id;
}
Database: Postgresql 8.4, Hibernate annotations 3.5.0-Final.
When saving the object of MyClass it generates the following SQL query:
select nextval('my_table_id_seq')
So there is no schema prefix and therefore the sequence cannot be found. When I write the sequenceName like
sequenceName = "my_schema.my_table_id_seq"
everything works.
Do I have misunderstandings for meaning of schema parameter or is it a bug? Any ideas how to make schema parameter working?
© Stack Overflow or respective owner