result 2 « Query « JPA Q&A





1. Criteria Query and typesafe Java Result Object    forum.hibernate.org

Hi, I know that you can return a typesafe Java object from a HQL Query e.g: select new Family(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr Is it possible to return a typesafe Java object from a Criteria Query? Somthing similar like: "Criteria crit = sess.createCriteria(DomesticCat .class).returnAs(Family.class);" Best regards, Christian

2. streaming hibernate query result sets    forum.hibernate.org

I have a requirement to select an entire table and return it in CSV format. I am using a hibernate query to perform the select. By default I get a List object back from the query and have to iterate through the list and create the response stream. Ideally I would like the hibernate query to write the results to an ...

3. Duplicate select results in when user is in multi-roles    forum.hibernate.org

I have a "User " model class, a "Role" model class, and a "Gene" model class which are maped to a user table, a role table, a user-role table and gene table There are four roles (ROLE_ADMIN, ROLE_RESEARCHER and ROLE_COLLABORATOR and ROLE_PUBLIC. A user may have multi-roles User { // private ...... private Set roles = new HashSet(); .... @ManyToMany(targetEntity = ...

4. scrollable result sets are not enabled    forum.hibernate.org

We have production code running for some time now. Yesterday, we suddenly received the following error: 2008-05-19 09:17:03,901 ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) org.hibernate.AssertionFailure: scrollable result sets are not enabled at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:475) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547) at org.hibernate.loader.Loader.scroll(Loader.java:2285) at org.hibernate.loader.criteria.CriteriaLoader.scroll(CriteriaLoader.java:89) ...

5. Count and results query combined    forum.hibernate.org

Hi I am trying to use Hibernate to create the following queries using Criteria and HQL. I had been able to do this via Critieria and Projections e.g. obtianing results and resetting Projection and reusing the Critieria to get the rowcount(). However looking at the generated sql this causes Hibernate to fire off 2 queries, which is not what we want. ...

6. Count and results query combined    forum.hibernate.org

Hi I am trying to use Hibernate to create the following queries using Criteria and HQL. I had been able to do this via Critieria and Projections e.g. obtianing results and resetting Projection and reusing the Critieria to get the rowcount(). However looking at the generated sql this causes Hibernate to fire off 2 queries, which is not what we want. ...

7. strange SQL query result    forum.hibernate.org

Hibernate version: 3.2.6 Hi, I'm trying to execute an SQL query Code: SELECT ts.UserId , ts.friendid , t1.friendid , t2.friendid , ...

8. Restricting collection results in query    forum.hibernate.org

I'm using Hibernate 3.2 and have an object model where a class called Track has many time-ordered TrackPoints in a one-to-many relationship. I would like to build a HQL query that would return me a Track object, but with only a subset of its associated TrackPoints based off a Calendar value. I looked through Chapter 14 of Java Persistence with Hibernate, ...





10. Selecting result count with Criteria.    forum.hibernate.org

I'm using Criteria with setFirstResult/setMaxResults to retrieve a subset of the result set (for paging results on a web page). However, I also want to know the total number of results in the result set. What's the most efficient way to do this when using Criteria? I could run two queries, one with the subset, and one with the full set, ...

11. Retrieving query results    forum.hibernate.org

12. Retrieving query results    forum.hibernate.org

you can check the type with the instanceof operator. Otherwise you might have to build up or retain some metadata to map a field named "location" to the correct type or even just to a handler that can interpret your location piece of data. I don't think hibernate has the ability to help you at this point so you'll have to ...

13. Retriving Custom Query Result    forum.hibernate.org

14. Getting result count with Criteria API    forum.hibernate.org

15. unable to cache Named query results for more than 2 minutes    forum.hibernate.org

Hi, I am trying to cache named queries in JPA, to cache the Named Query results for a particular time period of more than 20 minutes. I have written the ehcache.xml and defined the same reference in the persistence.xml, In the Entity option object, for the Named Query I have defined the Hints --> QueryHint = cacheable to true and the ...

16. use hibernatetemplate to select from middle of results?    forum.hibernate.org

I need to get at the records in the middle of a table, but the table is too large to load the entire thing into memory. In SQL this could be accomplished (admittedly somewhat inefficiently) like this: select top 10 (*) from post where id not in(SELECT top 10 id from post order by postdate) order by postdate This would select ...





17. Trying to Order results with Criteria object w/ a twist...    forum.hibernate.org

Hello all, I'm new to Hibernate, Java developer for 7+ years. I've got two Hibernate books that I have reviewed and started working with. I am writing code that is trying to do the following: Open a transaction Create criteria with restrictions Order by... BUT the order by that I need to order by is VoterHistory.election.electionDate's date In the class VoterHistory, ...

18. unmapped classes as sql query result    forum.hibernate.org

Hi, Is there a way to use unmapped classes as return type of named sql querys? e.g. Code: