-->
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: Facing a problem with Hibernate
PostPosted: Mon Apr 25, 2005 8:16 am 
Newbie

Joined: Mon Apr 25, 2005 8:06 am
Posts: 1
Hi,



I am facing a problem with Hibernate. The problem statement is as follows:



The table structure is:


Column Type Type
name schema name Length Scale Nulls

------------------------------ --------- ------------------ -------- ----- ------ -----------------------------------------------

I_WINET_ID SYSIBM BIGINT 8 0 No ---PK

C_PROPERTY_CODE SYSIBM VARCHAR 10 0 No --- PK

D_START SYSIBM TIMESTAMP 10 0 No ----- PK







I_SEQUENCE_NUMBER SYSIBM BIGINT 8 0 No








Now, there are 27 possible values for Property Code field.



When a new row is to be inserted into the table, depending on the property code , the value of the Sequence Number field should be set to the next value of a sequence.



For eg the insertion will be :



winetId, property code, d_start, sequence no



124587 AKC (current timestamp) 1 ---------

-- 1st record for AKC… therefore seq : 1



214578 RLV (current timestamp) 1 ----------

- 1st record for RLV ….. therefore seq: 1



212548 AKC (current timestamp) 2 -----------

2nd record for AKC ….. therefore seq: 2





548789 AKC (current timestamp) 3 -----------

3rd record for AKC ….. therefore seq: 3





875445 RLV (current timestamp) 2 -----------

2nd record for RLV ….. therefore seq: 2





I thought of creating different sequences for the possible values of propertyCode…but, Hibernate doesn’t give us control of a sequence ( as in we cannot specify which sequence to apply on what condition). Also, I think it does not allow to map a sequence with a non primary key.



We are using Hibernate 2.1.7

Any pointers as how to solve this?

_________________
----- Nagarajan.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 25, 2005 8:24 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Seems like you could solve this either with a formula property or an onSave interceptor?


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.