-->
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 Query By Example(QBE) to perform range search
PostPosted: Sun Sep 13, 2009 10:17 pm 
Newbie

Joined: Sun Aug 23, 2009 4:09 am
Posts: 1
Is this possible? Or must a use a combination of QBE & QBC? Below is my class:

public class Persona
{
public virtual int PersonaID { get; set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual int Level { get; set; }
public virtual int Strength { get; set; }
public virtual int Magic { get; set; }
public virtual int Endurance { get; set; }
public virtual int Agility { get; set; }
public virtual int Luck { get; set; }
}

What I'd like to do is perform a LIKE search against string properties and perform a range search search against the int properties. Currently, my code is as follows:

IList<Persona> personas = session.CreateCriteria(typeof(Persona))
.Add(Example.Create
(
new Persona()
{
Name = name
}
)
.IgnoreCase()
.EnableLike(MatchMode.Anywhere)
.ExcludeProperty("ModifiedOn")
.ExcludeZeroes())
.Add(Expression.Ge("Strength", 3))
.List<Persona>();

but I was wondering if there is a way to use only QBE? In doing so, I could eliminate the need to add additional logic to see if the user has provided a min/max value for Strength, Agility, etc and adding QBC's if values exist.


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.