-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Primary key sequence generator
PostPosted: Wed Sep 08, 2004 5:20 am 
Newbie

Joined: Wed Sep 08, 2004 5:01 am
Posts: 1
Location: Japan
Hibernate version:
hibernate-2.1

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="com.a2suite.domain.model.OnlineOrder"
table="ONLINE_ORDER"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="orderNumber"
column="ORDER_NO"
type="int"
>
<generator class="sequence">
</generator>
</id>

<property
name="memberNumber"
type="int"
update="true"
insert="true"
column="MEMBER_NO"
not-null="true"
/>

<property
name="totalMoney"
type="int"
update="true"
insert="true"
column="TOTAL_MONEY"
not-null="true"
/>

<property
name="totalTax"
type="int"
update="true"
insert="true"
column="TOTAL_TAX"
not-null="true"
/>

<property
name="orderDay"
type="java.sql.Timestamp"
update="true"
insert="true"
column="ORDER_DAY"
not-null="true"
/>

<property
name="collectNumber"
type="java.lang.String"
update="true"
insert="true"
column="COLLECT_NO"
length="16"
/>

<property
name="lastUpdateDay"
type="java.sql.Timestamp"
update="true"
insert="true"
column="LAST_UPD_DAY"
not-null="false"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-OnlineOrder.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Postgres 7.1
Debug level Hibernate log excerpt:


I have a table name Online_Order, with primary key order_no, and also a Unique column name, collect_no. I try to set It increment in order_no then, it works. What I want to do is to set the unique collect_no column in this format YYYYMMDD-XXXXX, which YYYYMMDD is no problem. but the XXXXX part will be like this 00001, 00002, .... every time data is inserted in this table. the XXXXX part will increment. I try to set collect_no to be the id param, but It didnt allow. Then It is possible to first set the order_no primary key that will evaluate the XXXXX part, then get the value of it to be assign in colect_no?

I am not sure how? any help would be greatly appreciated!

Thanks!

_________________
yuubouna


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 7:26 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
You can write an Interceptor with an appropriate onFlushDirty method.

HTH
Ernst


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.