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.  [ 4 posts ] 
Author Message
 Post subject: Mapping issue: how to use one column for more than one index
PostPosted: Sat Jul 26, 2008 3:54 pm 
Newbie

Joined: Sun Jun 22, 2008 1:57 pm
Posts: 11
Hi,

I have a table linked to two others and I need to create two indexes for this table with one common column.

For instance: my ALERT table has a type which is mandatory in the index used when I retrieve alerts for a user and when I retrieve alerts for an automation module. The both sources can create/generate alerts.

Code:
             USER               MODULE
                |_________________|
                        |
                       ALERT: one index for the user and one for the module
                              with different columns for each one and the alert type
                              in common


I tried to specified two "index" attributes, and one index attribute with two columns separeated by a "," or ";". But id did not work.

My question : how can I specify for a column that it is part of two multiple column indexes?

Thank for help,
C-Rock


Top
 Profile  
 
 Post subject: Re: Mapping issue: how to use one column for more than one index
PostPosted: Tue Sep 22, 2009 6:19 pm 
Newbie

Joined: Tue Sep 22, 2009 5:35 pm
Posts: 4
C-Rock,
Did you get any help or solve your problem about muliple indexes? I have a similar situation.
Riley


Top
 Profile  
 
 Post subject: Re: Mapping issue: how to use one column for more than one index
PostPosted: Sat Oct 03, 2009 1:32 am 
Newbie

Joined: Sun Jun 22, 2008 1:57 pm
Posts: 11
Hi Riley,

Unfortunately no, I just addressed my problem by a "design" workarround.


Top
 Profile  
 
 Post subject: Re: Mapping issue: how to use one column for more than one index
PostPosted: Mon Oct 05, 2009 4:04 pm 
Newbie

Joined: Fri Oct 02, 2009 1:12 pm
Posts: 3
As far as I know, this approach is not possible with pure HBM configuration. You may be able to write an HQL query; I personally would prefer some other means. The most likely to work like you intend? Design your Alert class with two private fields, userId and moduleId. Map the two possible alert sources to those fields using Field access (it shouldn't matter that they're private as long as NHibernate looks for the correct name), then use a single property to expose them, with the simple rule that if the first is null or empty, return the second. If you need a setter, this becomes more complex, and I would recommend fully implementing properties for both backing fields and figuring out which to use in your BL code.


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