Hi,
Assuming the following scenario:
class Project{
public Job Job;
}
class Job{
public Name;
}
Assuming I want to use the Criteria API to search for all projects whose Job has the name "sumthing".
I could use the CreateAlias to create an alias for Job and use it to access Name, or I could create a new Criteria for the proper...
I'm trying to do a like search against an integer column, what I need to do is actually cast the column to a varchar and then do the like search. Is this possible? what's the easiest way to do this using the Criteria API?
var search = "123";
criteria.Add(Restrictions.Like("Number", "%" + search + "%"))
...
Assuming I have classes User and UserGroup. There is an optional 1-many group to user association and the association is mapped from both sides (the UserGroup side via a property called "members", which is a HashSet, the User side via property "group").
Using the Criteria API, how can I query for all groups, sorted by count of group mem...
I'd like to use Hibernate's Criteria API for precisely what everybody says is probably its most likely use case, applying complex search criteria. Problem is, the table that I want to query against is not composed entirely of primitive values, but partially from other objects, and I need to query against those object's id's.
I found th...
Hi,
I need help with an nhibernate query. I would prefer to use Criteria API if possible, otherwise HQL is ok.
I have an Employee object with an Account object property, the Account has a collection of Entry objects, and each Entry has an Amount property. (see class diagram).
http://www.threeboxes.com.au/employeeQuery1.jpg
I need a q...
I have the following domain set up for persistence with NHibernate:
I am using the PaperConfiguration as the root aggregate.
I want to select all PaperConfiguration objects for a given Tier and AcademicYearConfiguration. This works really well as per the following example:
ICriteria criteria =
session.CreateCriteria<PaperConfiguratio...
Suppose I have classes like:
class A {
B getB();
C getC();
}
class B {
String getFoo();
}
class C {
int getBar();
}
and I want to filter criteria on A, two filters on different subclass properties, like:
Criteria criteriaA = session.createCriteria(A.class);
Criteria criteriaB = criteriaA.createCriteria("b").add(Restrictions.eq(...
I had a scenario in Oracle where i neeed to match a substring part of column with a list of values. i was using sqlfunction projection for applying the substring on the required column , and addeed that projection as part of an In Clause Restriction. Below is the simplified criteria i wrote for that.
ICriteria criteriaQuery = session.C...
Hi
I am trying to use Criteria API in following scenario:
I have two tables, Schedule and Route (with their classes and mappings).
Route has many-to-one relationship with Schedule.
Route has an integer property sequence.
Now I need to fetch all those Schedule objects whose associated Route objects fulfill the following condition:
r...
Hi,
I have a paging method that uses the criteria API's SetMaxResults and SetFirstResult. Functionally, it works fine.
What I'd like to do now is provide another method that retrieves the index of a given item within the set of all items, thus allowing me to calculate what page that item is in.
I am able to calculate the index correct...
I am still new to Hibernate and am attempting to use it for a web site I have inherited. Unfortunately that means sometimes the db schemas don't always make sense.
With that said, I am trying to build the following HQL query using the Criteria API
from TableB b where b.id = :id and b.TableAProperty.UserId = :userId
The above HQL sta...
I'm having trouble converting the following HQL-query to Criteria API and I was wondering if I could get some help from you guys
SELECT child FROM Foo AS child
WHERE child IN (SELECT elements(obj.foos) FROM Bar AS obj WHERE obj.id = ?)
In other words, I want to fetch all Foos that Bar references to in the instance of Bar whose id ...
How is this possible, I have to following criteria
Criteria criteria = getSession().createCriteria(c);
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
criteria.add(Restrictions.eq("active",true));
List list = criteria.list();
The size of list is now 20. If I add a max results to the criteria,
Criteria criteria = getSes...
Hi all,
I want to perform a LEFT OUTER JOIN between two tables using the Criteria API. All I could find in the Hibernate documentation is this method:
Criteria criteria = this.crudService
.initializeCriteria(Applicant.class)
.setFetchMode("products", FetchMode.JOIN)
.createAlias("products", "product"...
Hi all, I am doing a LEFT OUTER JOIN, but I am only able to apply Restrictions on the first table. Is there a way ti apply on the second table as well?
Here is my code:
Criteria criteria = this.crudService
.initializeCriteria(Applicant.class).setFetchMode("products",
FetchMode.JOIN);.
This works (applicant has a...
List<object[]> products = GetSession().CreateCriteria<Product>()
.SetProjection(Projections.ProjectionList()
.Add(Projections.Property("Id"))
.Add(Projections.Property("Name"))
.Add(Projections.Property("Price"))
)
...
Hi,
I want to translate a HQL query to Criteria API but I don't know if it's possible to write the same thing with Criteria.
The HQL looks like this:
select distinct new DataTransferObject(property1, property2, ..., (select NVL(property3, null) from Table1 where property3 in elements(...) and ... ), property4, ..., (select .....), ...)...
EDIT: I've edited this post completely, so that the new description of my problem includes all the details and not only what I previously considered relevant. Maybe this new description will help to solve the problem I'm facing.
I have two entity classes, Customer and CustomerGroup. The relation between customer and customer groups is M...
Has anyone implemented this, or know if it would be difficult to implement this/have any pointers?
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
// TODO: Implement
throw new NotImplementedException();
}
from NHibernate.Spatial.Criterion.SpatialRestrictio...
Hello,
For instance if I do something like:
Criteria c = session.createCriteria(Book.class)
.add(Expression.ge("release",reDate);
.add(Expression.ge("price",price);
.addOrder( Order.asc("date") )
.setFirstResult(0)
.setMaxResults(10);
c.list();
How can I use the same cr...