createCriteria « Query « JPA Q&A





1. Can I select specific columns with Hibernate "createCriteria()"?    stackoverflow.com

I used createCriteria() and setFetchMode() methods to join and select. I don't need all columns so I want to select specific columns to improve performance, but I can't find how to ...

2. Hibernate createCriteria on an interface causes N queries rather than 1    stackoverflow.com

My situation is this: We have a superclass, "MyAbstractEntity"

@Entity
@Table(name = "MyTable")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "DISCRIMINATOR", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("FOO")
public abstract class MyAbstractEntity implements Comparable<MyAbstractEntity> {
This class in turn has quite a few subclasses, ...

3. createCriteria executes the select query multiple times    forum.hibernate.org

i use createCriteria with uniqueResult to select an object by id as follows: 1- Service: Code: @Service @Transactional public class MyService { public Employee getEmployeeById(long employeeId) { ...

4. using createCriteria with aggregate function "sum"    forum.hibernate.org

Hi there, I am a newbie. But I managed to create a small application using hibernate and mysql database. There is one thing which I am trying to achieve but not sure how. There is a report which is generated from a view. I provide search parameters using a struts form bean and get the results in a arraylist. Works like ...

5. createQuery and createCriteria    forum.hibernate.org

The code given below works Query query = session.createQuery(findTokens); Date d1 =Date.valueOf("2005-03-10"); query.setDate( "processInstanceStart", d1); query.setString( "actorId", actorId ); but when i specify this with criteria it fails classCriteria crit = session.createCriteria(TokenImpl.class ); Criterion userEq=Expression.eq("actorId",actorId); crit.add(userEq); Date d1 =Date.valueOf("2005-03-10"); Criterion processInstanceStartEq=Expression.eq("processInstance.start",d1); crit.add(processInstanceStartEq); the query goes like this private static final String findTokens = "select t " + "from t in class ...

6. select from createCriteria    forum.hibernate.org

Mapping: seq_parent_id seq_child_id

7. Pagination. createcriteria and createQuery transformation    forum.hibernate.org

HI All, I am using Hibernate 3.0 and Oracle 8i. I am implementing pagination where the user would like to get the results as Google. Previous 1 2 3 4 5 6 7 8 9 Next. After reading the articles in the forum, the only solution was to use the follwing code. Query query = s.createQuery(queryString); query.setFirstResult(pageNumber * resultsPerPage); query.setMaxResults(resultsPerPage); List ...

8. Simple Query help using session.createCriteria    forum.hibernate.org

Hi All, I need help in writing a simple query. Just not able to do it. I am breaking my head and just don't know how to do this using Criteria. I have a Project and this project has multiple tasks. I have defined a set for the task. Code:

9. Ordering Results in createCriteria    forum.hibernate.org

no, you didn't. If your column is date, it should be mapping to date. If you want to have a nicely formatted date for your user interface, you can create a getter that returns a String, maybe using a SimpleDateFormat r something alike, but the ordering must be done through the real date, mapped as a date. If the ordering seems ...





10. how to use union option in createCriteria with projections    forum.hibernate.org

Hi, i want to know how to write this two query in Hibernate using createCriteria along with projections. 1. select sum(setteld_bal) from account_balances where clientaccount = 84 and bal_type_ind=1 union select sum(setteld_bal) from account_balances where clientaccount = 84 and bal_type_ind=2 2. select sum(setteld_bal), bal_type_ind from account_balances where clientaccount = 84 and bal_type_ind in (1,2) group by bal_type_ind

11. how to sort the derived columns using HQL and createCriteria    forum.hibernate.org

Hi All, I have two tables like person and address. The relationship between Person and address are one to many. I want to display the details of person including his addresses in a single row. As shown below. Person Address Person_Id ID, Addr_ID Name Street Addr_ID City Zip Example: Person Address Address 10 10, 1 20, 1 purushotham Bukkarayasamudram Perungudi 1 ...

12. how to implenet my query (with subquery)in createCriteria    forum.hibernate.org

Hi , I have Query as follows , select * from AUDIT_LOG where DOC_ID in (select doc_id from INFORMATION where DOC_ID =261) I would like to implement in the createcriteria. Can any one suggest me how to implement? Actually I am facing problem of association . I have 1 more tabel in addation to the above. this is the main table ...

13. How to createCriteria using this query joins?    forum.hibernate.org

Hi All, Any one help me createCriteria using Joins ... Pls find the given below joins query : public List getJobseekerWorkExperience(Integer id) { StringBuffer selectClause = new StringBuffer( " select jswe.employerName, jswe.employerAddress, jswe.startFrom, jswe.endTo, jswe.visible, jswe.sortOrder, "); selectClause .append(" jswel.businessSector, jswel.occupationTitle, jswel.mainActivities, jswe.id "); StringBuffer fromClause = new StringBuffer( " from CvoJsWorkExperience as jswe, "); fromClause.append(" CvoJsWorkExperienceLingual as jswel "); StringBuffer ...