OK.... No i am getting the flavor
1st Issue : Is to pass the name of sequence/identity already created in DB to hibernate
2nd Issue : Hibernate should switch bw seq/idenity as application hits any of the D/B
(pls correct me if m getting it wrong...:))
Hmmmm first i tried creating a sequence in oracle
Code:
CREATE SEQUENCE AKASH.SAMPLE_SEQ
START WITH 21
MAXVALUE 99999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;
and gave the name to hibernate
Code:
<id name="clockID" type="java.lang.Integer">
<column name="CLOCKID"/>
<generator class="sequence">
<param name="sequence">sample_Seq</param>
</generator>
</id>
hibernate picked the sequence and worked as expected
Code:
INFO: HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select sample_Seq.nextval from dual
Hibernate: select sample_Seq.nextval from dual
Hibernate: select sample_Seq.nextval from dual
Hibernate: insert into CLOCK (CLOCKNAME, ISINDIGLO, CLOCKID) values (?, ?, ?)
Hibernate: insert into CLOCK (CLOCKNAME, ISINDIGLO, CLOCKID) values (?, ?, ?)
Hibernate: insert into CLOCK (CLOCKNAME, ISINDIGLO, CLOCKID) values (?, ?, ?)
--------------------Fetching Values From the Database---------------------------
Hibernate: select clock0_.CLOCKID as CLOCKID0_, clock0_.CLOCKNAME as CLOCKNAME0_, clock0_.ISINDIGLO as ISINDIGLO0_ from CLOCK clock0_
Clock [clockID=4, clockName=Timex WR30M, isIndiglo=false]
Clock [clockID=5, clockName=Timex SR51M, isIndiglo=true]
Clock [clockID=6, clockName=Timex TR61M, isIndiglo=true]
I think i was able to simulate the 1st issue ... I am trying to work on 2nd issue in the meantime please pass onto your comments...