Customization default sequence name. [message #516846] |
Thu, 25 February 2010 06:06  |
Radek Hodain Messages: 16 Registered: February 2010 |
Junior Member |
|
|
Hi all.
I would like to ask you, how to customize default sequence name.
We use Oracle database. In entity mapping we use something like this:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "entity_id")
private Integer id;
My first task is to set up the SequenceGenerator as a default generator, because OraclePlatform chooses the TableGanerator as default for GenerationType.AUTO.
I did it via SessionCustomizer
public void customize(Session session) throws Exception {
session.getLogin().setDefaultSequence(new NativeSequence());
}
Now, when I use Generation.AUTO eclipse link uses SequenceGenerator and produces SQL like this:
SELECT SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL.
My second task is to modify SQL. We use sequence name based on table name. So, our sequence name are SEQ_USER or SEQ_GROUP etc. Default sequence generator uses the static sequence name. I will get the same sequence name from all entities. Does anybody know how to build sequence name dynamically with table name of entity. I have tried to build own SequenceGenerator but I am not able to get table name there.
PS: We have solved it in hibernate and openjpa whose generate sequence name dynamically but I am not able to find this feature in eclipselink. If I don't use annotation SequenceGenerator or TableGenerator with definition I get every time the same static sequence name or table name.
Thanks a lot for your advice.
[Updated on: Fri, 26 February 2010 04:25] Report message to a moderator
|
|
|