Questions tagged [criteriaquery]

245 questions
0
votes
1 answer

is it possible to create criteriaquery in JPA2 using foreign key value?

let say I have 2 tables joined by one-to-many relation public class Slave { @Id @Column(name = "id") long id; @JoinColumn(name = "master", referencedColumnName = "id") Master master; } public class Master { @Id @Column(name =…
mirec
  • 627
  • 1
  • 8
  • 23
0
votes
0 answers

Retrieving a list of entites based on an array of ids

I have an array of ids, long[] ids, and I want to retrieve a List of entities that have the ids from the id array using CriteriaQuery. I tried to achieve this with the following code: for (int i = 0; i < orderIds.length; i++) { …
0
votes
1 answer

Hibernate Criteria Query select where clause

person: id | owner_email | firstname | lastname ----+-------------+-----------+---------- 44 | john@gmail.com | john | wood 45 | alex@gamil.com | alex | greenwood 49 | peter@gamil.com |…
sefirosu
  • 2,558
  • 7
  • 44
  • 69
0
votes
1 answer

JPA Criteria Build how to use Order By Clause with ASC NULLS FIRST

How can I use the "order by" clause with "asc nulls first"? This is my code: CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery query = builder.createQuery(MyClassModel.class); //esprToOrder is a Expression istance…
bancomat
  • 15
  • 6
0
votes
1 answer

Criteria Query JPA : insert into select

Is it possible to do the following SQL query with CriteriaQuery (EclipseLink) ? INSERT INTO my_table (SELECT columns FROM other_table)
Libert Piou Piou
  • 540
  • 5
  • 22
0
votes
2 answers

What is return type for grails service function?

I having a grails service function like this public List getfunction(def test, def test1) { def criteria = Test.createCriteria(); List list= criteria.list { projections{ groupProperty('state') …
0
votes
3 answers

Add SQL condition to CriteriaQuery

I need add something like Restrictions.sqlRestriction to CriteriaQuery. How to add SQL condition to CriteriaQuery? My code: CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder(); CriteriaQuery criteriaQuery =…
Akvel
  • 924
  • 1
  • 15
  • 32
0
votes
1 answer

How set where in templates using jpa in CriteriaQuery

I am beginner in java EE and I need know, how set a clausule where in this code of criteria public List findEntity(Class entityClass) { CriteriaQuery criteria = builder.createQuery(entityClass); Root entityRoot =…
rodrixd
  • 510
  • 2
  • 6
  • 15
0
votes
0 answers

Select a child from a Parent through CriteriaQuery through subqueries

Does any have anyone have an idea of how i can return an distinct array of product from a ProductCategory through CriteriaQuery using subqueries! I tried these tutorial but it didn't work: Subquery in where clause with CriteriaQuery public String[]…
Abiodun Osinaike
  • 155
  • 1
  • 4
  • 14
0
votes
1 answer

Exception in getting list from CriteriaQuery

for some reason i can't tell, there is exception when i try to get a list from CriteriaQuery using subquery. some one please help!!! here is the code: public String[] getProductsDistinctBySubQueriesName(String category) { CriteriaBuilder builder…
Abiodun Osinaike
  • 155
  • 1
  • 4
  • 14
0
votes
1 answer

No results retrieved from database view using Java

I have a view named V_ENTITY in my database which is populated with a few entries. Using SQL scrapbook in Eclipse I can easily do queries which return desired results. However, when I try to retrieve the entries from my DAO class, I get nothing. My…
ioreskovic
  • 5,531
  • 5
  • 39
  • 70
0
votes
1 answer

JPA and JPQL MEMBER OF queries always returning empty results

I am having problems with JPA2/Hibernate 4.2/MySQL 5.1/Java 6 I have the following class, User, which has an attribute, Set, where Role is an enum. Here is the class: @Entity public class User { private static final long serialVersionUID =…
fancyplants
  • 1,577
  • 3
  • 14
  • 25
0
votes
1 answer

CriteriaQuery JPA 2 issue with results

I am using JPA 2 with Hibernate to construct a query that for the life of me wont run correctly. Query below: public Integer getCountForDAR(Date _SD, Date _ED, Integer _PostId, String _Filter) { CriteriaBuilder cb =…
0
votes
1 answer

Criteria Query with multiple cascaded joins involved

I have three entities: Block, Viewand TargetBlockand want to create a JPA Criteria query for the following sql. select * from Block INNER JOIN TargetBlock tb ON tb.blockID = b.blockID INNER JOIN view v ON tb.viewID = v.viewID Block has many views…
user942309
  • 61
  • 1
  • 1
  • 6
0
votes
2 answers

JPQL Criteria Query Play Framework 1x Inner Join And Where Clause Construction

I am stuck trying to build the following SQL query in JPA (still new to Java and JPA and I searched quite a bit and still don't get it, sorry if it's a noob question). JPQL query that does almost what I want and works SELECT s FROM Sentence s INNER…
bladmiral
  • 225
  • 1
  • 11
1 2 3
16
17