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: IQuery with Enumerations Help
PostPosted: Mon Nov 19, 2007 1:03 pm 
Newbie

Joined: Fri Nov 16, 2007 6:20 pm
Posts: 15
After examining some my problem outlined in this post, I realized it was my IQuery that was causing problems. I'm hoping what I'm attempting is possible.

What I have is a Project business object that contains a bag of "Mode" enumeration types. This is essentially a many-to-many relationship to a look-up table, except I'm eliminating the look-up table in favor of an enumeration.

I want to be able to perform the following IQuery:
Code:
IQuery query =
                NHibernateSession.CreateQuery(
                    "FROM Project as pj WHERE pj.Modes IN (:ProjectModes) ");

ArrayList projects = new ArrayList();
projects.Add(ProjectMode.Mail);
projects.Add(ProjectMode.Phone);

query.SetParameterList("ProjectModes", projects);


In essence, "All the projects that have modes in a provided list of project modes".

Am I even approaching this the right way?
Is this even possible?
Would I be better served to just create a modes business object an map it to a table?

The Enum:
Code:
public enum ProjectMode
{
     Web = 0,
     Mail,
     DataEntry,
     Phone,
     Consulting,
     DataAnalysis,
     FocusGroup,
     CognitiveIntrviews,
     Other = 100,
}


Snippet from the Project.hbm file:
Code:
<bag name="Modes" access="property" lazy="false" cascade="none" table="ut_ProjModes">
      <key column="prKey"/>
      <element column="prMode" type="SESRC.Scheduler.Core.Domain.ProjectMode, SESRC.Scheduler.Core" />
    </bag>


DDL for the mapping table:
Code:
CREATE TABLE [dbo].[ut_ProjModes](
   [prKey] [int] NOT NULL,
   [prMode] [smallint] NOT NULL
)

prKey - Project table
prMode - Mode "table", which I'm trying to replace with an enumeration.


Thanks
Jack


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.