开发者

Identity Generator in Hibernate with Sybase

I am using hibernate 3.5 with Sybase ASE database.I have a primary key PK1 in my table Table. I used the select generator class for my primary key generation.

<id name="pk1" type="java.math.BigInteger">
            <column name="PK_ID" />
              <generator class="select">
                  <param name="key">unique</param>
              </generator>
</id>

I have one more class which uses the PK_ID as foreign key but not a primary key.I have kept the mapping for it as,

<property name="PK_ID1" type="java.math.BigInteger">
            <column name="SHIP_EVENT_ID" length="23" not-null="false" />
</property>

When I use identity generator this seems to work fine.But when I change it to select generator.It shows me constraint violation exception.Although the new value is being generated and set to the pojo class for the second table.

Please Help!

开发者_如何学Go

Regards, Dwarak


With an engine like ASE in the back end, it is not a good idea to use some OO front end to do your DDL changes. Sure, this is a bug in the front end, but this is not the only one. More important you have access to only about 5% of Sybase functionality. Why don't use the Sybase Client softwarw that comes free with ASE. SybaseCentralfor all your DDL and Administrative tasks and InteractiveSQL for all your SQL tasks (DML, stored procs, testing SQL). It is not only more direct, it is much faster development time. Once you have the objects set up and tested, use whatever front end you like to execute commands (either stored procs or tested SQL) against those objects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜