So I have Transactions and GLAllocations. I want to get all Transactions that don't have a corresponding record in the GLAllocation table. The following SQL produces the results I want.
select t.* from [Transaction] t
left join [GLAllocation] gla on gla.TransactionID = t.TransactionId
where gla.glid is null
Is there a way to represent...
Here is roughly our data model (the entity names are fake and only for example purposes).
Product has a many-to-many relationship with Shipper. Shipper then has a one-to-many relationship with Warehouse.
Basically: Product has many Shippers which have many Warehouses.
We have a mapping from Product to Shipper and from Warehouse to Shi...
Is there Hibernate criteria like queries in JPA?
...
Hi,
short version: is there a HQL equivalent for session.CreateCriteria(string)?
Long version:
The mapping looks like this:
<class name="MyClass" entity-name="MyClass">
...
</class>
<class name="MyClass" entity-name="SomeEntityName">
...
</class>
When I use session.CreateCriteria("SomeEntityName"), only objects stored...
For some reason I can never figure out how to do things via criteria api.
I have a HQL:
from Track track where size(track.trackTitles) > 1
Is it possible to convert it into a criteria query on Track class? If yes, how: what Restriction should I use?
...
Each Store has many Products.
Store --> (N) Products
How to create an NHibernate criteria to get stores with more than 2 products which price is greater than 2.0$ ?
I know how to get Stores based on a criteria on Products and I also know how to get the count of Products which Price is greater than 2, but I can't find a way to put ...
I want to do the simplest job: Getting products which name is "Potatoes".
// solution 1 - Using Expression.Eq
return session.CreateCriteria<Product>().Add(Expression.Eq("Name", "Potatoes")).List<Product>();
// solution 2 - Using Example
Product exampleProduct = new Product();
exampleProduct.Name = "Potatoes";
return session.Cre...
Hi Guys,
I'm trying to get a report using Criteria and ProjectionList, and I'm pretty new using this through hibernate.
So I have this model:
private Long _userId;
private Category _category;
private Long _companyId;
private Double _amount;
private Date _date;
And I building the query using this:
public List sumPaymentsByU...
Hello,
I'm building application that uses JPA, and I want to use Criteria API as described http://openjpa.apache.org/builds/latest/docs/manual/jpa_overview_criteria.html. More precisely this part:
EntityManager em = ... ;
CriteriaBuilder queryBuilder = em.getCriteriaBuilder();
CriteriaQuery qdef = queryBuilder.createCriteriaQuery();
...
Hi,
I have three entities ClassA, ClassB and ClassC.
ClassA {
...
@Id
@GeneratedValue
@Column(name = "a_id")
private long id;
...
@OneToMany(cascade={CascadeType.ALL})
@JoinColumn(name="a_id")
private List<ClassB> bbb;
...
}
ClassB {
...
@ManyToOne
private ClassC ccc;
...
}
ClassC {
...
private String name;
...
}
I...
How is something like this done in linq? It has filter criteria on the JOIN.
This is taken from this question: http://stackoverflow.com/questions/1401889/sql-filter-criteria-in-join-criteria-or-where-clause-which-is-more-efficient
select salesman.salesmanid, max(sales.quantity)
from salesman
inner join sales on salesman.salesmanid =sa...
Consider the following three Hibernate entities:
public class Car {
@OneToMany(fetch = FetchType.LAZY)
@Fetch(FetchMode.SUBSELECT)
private List<Wheel> wheels;
}
public class Wheel {
@OneToOne(fetch = FetchType.LAZY)
private Hubcap hubcap;
}
public class Hubcap {
}
Consider the following Criteria:
Criteria criteria = ...
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 ...
I have the following graph:
OrderLine
OrderLineExtension
OrderLineExtensionA
OrderLineExtensionB
OrderLineExtensionC
OrderLine contains a Set of OrderLineExtension.
OrderLineExtension is defined as : @Inheritance(strategy = InheritanceType.JOINED) and is marked as an entity and is abstract
A table is creat...
Hello
Given the following tables, I am trying to return all Allocations for a given Resource's that fall between a given range of dates using a criteria query:
create table Resources (
ResourceId integer,
ResourceName TEXT not null,
BusinessId TEXT not null,
OrganizationName TEXT not null,
primary key (ResourceId)
)
c...
Hi,
Im trying to write an NHibernate criteria that effectively joins and restricts at the same time. My DB looks like this...
Cases ---> CustomerProducts <--- Customers
Cases ---> CaseStatuses
Each case is associated with a customer product (Many cases to one product).
Each customer has a number of customer products (One customer has...
I have an entity type A. Which has many B's. The B entity has many C's.
I need to count how many C's does an A entity have. How can this be done using NHibernate Criteria API?
Using LINQ to NHibernate I was unable to get results since it throws an exception (see this question)
...
I am trying to search for an xml node:
<Countries>
<Country FullName="AFRIQUE DU SUD" Code="ZA" IsOut="1" />
<Country FullName="ALLEMAGNE" Code="DE" IsOut="0" />
</Countries>
Selecting on the basis of CountryCode only:
xmlDoc.SelectSingleNode("//Countries/Country/@[Code='ZA']");
How do I also apply the condition so that I can c...
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"...