-->
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.  [ 1 post ] 
Author Message
 Post subject: Using Generators for Properties
PostPosted: Mon Nov 29, 2010 4:02 am 
Newbie

Joined: Tue Nov 11, 2008 8:19 am
Posts: 11
Hi All,

In the legacy DB there is a table called "Counter" which tells the next possible value of a business column (not identity). I have created a view on this table and implemented the org.hibernate.id.TableHiLoGenerator for this ID column. Now I have a scenario to use this "Counter" table for a property (which is not the primary key of that table column). How can i resolve this issue?

Is it possible to map a view with a property ???

<hibernate-mapping>
<class name="in.co.lic.stmp.insuranceagreement.domain.PlanMovementDo" table="PLANMVTS">
<id name="planMovementNumber" type="int">
<column name="PlanMvtId" />
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">view_IDGenerator_PlanMvtId</param>
<param name="column">planMvtId</param>
<param name="max_lo">0</param>
</generator>
</id>
<property name="origin" type="int">
<column name="ORIGIN" not-null="true" />
</property>
<property name="planNumber" type="string">
<column name="PLANNO" length="12" />
</property>
<property name="productType" type="int">
<column name="PRODTYP" not-null="true" />
</property>
</class>
</hibernate-mapping>


view_IDGenerator_PlanMvtId :
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER VIEW [dbo].[view_IDGenerator_PlanMvtId]

AS
SELECT VALUE AS PlanMvtId FROM Counter WHERE PARAMETERNAME = 'PlanMvtId'
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

_________________
Vinoth


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

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.