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...
Can somebody please help me complete / clean up this query. I am trying to first get the number of rows in the table, then I need to actually fetch a set of rows. I am not sure how I can use the same criteria instance to perform both queries.
To fetch the count I have something like this:
Criteria criteria = session.createCriteria(My...
I have an Oracle XMLType column that stores the various language specific strings. I need to construct a Hibernate criteria that orders on this column. In order to do this, I need to extract the value with an Oracle function. This criteria is generated automatically by code I have written but I cannot, for the life of me, figure out how ...
is possible with Hibernate criteria do it?
select A.something, B.something, C.something, D.something
from A JOIN B on A.id = B.id_fk
JOIN C ON B.id = C.id_fk
JOIN D ON C.id = D.id_fk;
...
Hello,
Before asking I have looked at all relevant posts on this topic
I have also read this blog post: http://ayende.com/Blog/archive/2007/12/23/NHiberante-Querying-Many-To-Many-associations-using-the-Criteria-API.aspx
I have Teams and I have Members, there is many-to-many relationship between them
Basically: Member -> MemberTeam <-...
Hello all.
I want to know how make NHibernate store my queries at 2-nd level cache for specified time
I see it only for entities cache.
Thank you for replying.
...
This is similar, but not identical, to:
http://stackoverflow.com/questions/1528352/hibernate-criteria-query-on-different-properties-of-different-objects
I have a SpecChange record, which has a set of ResponsibleIndividuals; these are User records mapped by a hibernate join-table association. I want to create a Criteria query for a Spec...
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...
Hi.
I'm writing a criteria that should group the results by a property of a related entity. I've tried using an alias, tried using the property path itself, but so far I get nothing.
say my classes are (rough sketch):
class A{
@ManyToOne(...)
B b;
}
class B{
@OneToOne(...)
C c;
}
class C{
String s;
}
and I want a criteria that r...
Hi All,
I have been sifting through pages on Google looking for the answer to no avail, however I think I am just phrasing the question incorrectly.
The scenario is as follows: I have an entity which users are able to either vote for or against. For arguments sake lets call the entity a business.
I would like to have a property on my ...
I have a Person class which has a String collection of aliases representing additional names that person may go by. For example, Clark Kent may have aliases "Superman" and "Man of Steel". Dwight Howard also has an alias of "Superman".
@Entity
class Person {
@CollectionOfElements(fetch=FetchType.EAGER)
Set<String> aliases = new Tr...
Hello,
I have a table Player with columns id, name, wins, games_played. I mapped it to a class Player.
I want to do the following query in Hibernate (preferably with Criteria, if not possible with Criteria HQL will also help)
select * from Player order by (wins /
games_played)
I expect to get List<Player> sorted by their win rat...
I have a Criteria with:
Criteria criteria= session.createCriteria(Libro.class).addOrder( Order.asc("ID") );
However, when I want to get the rowcount fail:
criteria.setProjection(Projections.rowCount());
because there is an order by in the query.
How to remove dinamically the ordering in the Criteria?
I mean, I am looking for like c...
I'm trying to unit test my DAO which uses the Criteria API. The Criteria object I have has a number of expressions and returns a unique result.
The problem I have is that when I use Jmock to create an expectation I have to create one for the criteria.uniqueResult() command and I have to set a return type. The return type is a custom ty...
Is it possible to perform a global reversed-find on NHibernate-managed objects?
Specifically, I have a persistent class called "Io". There are a huge number of fields across multiple tables which can potentially contain an object of that type. Is there a way (given a specific instance of an Io object), to retrieve a list of objects (o...
In my database I have a Person table and an Event table (parties, meetings, &c.). This many-to-many relationship is represented through an Invitation table. Each Person can have many Invitations. Each Event can also have many Invitations.
If I want a list of Events to which a Person is invited, I can use this HQL query:
IQuery query = ...
Hi There,
How would I go about executing the following Hibernate query using the criteria API.
I have an object Parent with List children. I would like to search through all parents and find which parents contain a specified child.
i.e. List<Parent> findParents(Child child);
Thanks.
...
Hi,
I have a specific DB2 query, and I would like to execute this query using criteria.
The query:
SELECT
sum(units) as volume,
location_id,
aged
FROM (
SELECT
units,
location_id,
CASE
WHEN daysinstock < 61 THEN 'NOT_AGED'
WHEN daysinstock < 91 THEN 'AGED'
ELSE 'OVER_AGED'
END AS AGED
FROM
STOCK_T...
I have a frustrating problem with the criteria builder. I have an application in which one user has one calendar, and a calendar has many entries. Seems straightforward enough, but when I try to get the calendar entries for a given user, I can't access the user property (MissingMethodException). Here's the code:
def getEntries(User user...
Hello,
I have the following mapping:
<hibernate-mapping package="server.modules.stats.data">
<class name="User" table="user">
<id name="id">
<generator class="native"></generator>
</id>
<many-to-one name="address" column="addressId" unique="true" lazy="false" />
</class>
<class name="Address...