-->
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.  [ 3 posts ] 
Author Message
 Post subject: Regarding custom generator on non primary column
PostPosted: Wed May 31, 2006 9:27 am 
Beginner
Beginner

Joined: Tue Feb 28, 2006 3:16 am
Posts: 28
I have one question regarding generator. Here is my requirement

1> I have one table which contains one column (say X) which is of string type but which contains only numbers.
2> This column is not an identity or primary key column.
3> Table contains some other primary key columns.
4> the value of X that needs to be generated at the time of saving the object should be like max(integer value of X)+1 , but as i mentioned this is not a numeric column.
5> I m not sure whether i can use the custom generator.

Can anyone give some pointers.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 12:57 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
We have several cases like this. We handle them the following way:

1. All of our entities implement a specific interface (which we call IEntity).

2. The IEntity interface defines a property of type IEntityStrategy. The IEntityStrategy interface defines methods SetDefaults() and Validate().

3. Both our implementation of IInterceptor.Instantiate(), and our entity factory (which creates new, transient entity instances) creates and attaches an instance of the appropriate strategy to the entity. When a transient entity is created, its strategy's SetDefaults() method is called. We then code whatever is necessary in SetDefaults() for that entity's strategy.

The strategy classes live in a separate DLL from the entities themselves, and are "persistence aware" (i.e. can execute HQL). If SetDefaults() needs to get some next sequence number, possibly based on some filter like a parent foreign key, by executing some HQL, it can do that.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 06, 2006 1:17 am 
Beginner
Beginner

Joined: Tue Feb 28, 2006 3:16 am
Posts: 28
hi

Ur answer bounce back over my head, i have following property in my mapping file.
Tell me what changes i need to do at mapping level and classes level.
Plz tell me step by step if possible.

<property name="RollupMap" column="RollupMap" type="String" length="5" not-null="false" />


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.