correct « Query « JPA Q&A





1. What is the correct syntax for an ejbql query that traverses four levels of many to one relationships    stackoverflow.com

I have a simple data model in JPA (hibernate) consisting of many to one and one to one relationships similar to this: town -> state -> governor -> nation -> continent where town ...

2. Correct sql/hql query (aggregate in where clause)    stackoverflow.com

I want to do query as below. Query is wrong but describes my intentions.

SELECT name, dateTime, data
FROM Record
WHERE dateTime = MAX(dateTime)
Update: Ok. The query describes intentions not quite good. My bad. I ...

3. Is my method for JPA querying is correct?    stackoverflow.com

I am using JPA in my web application and when I do not want the DB to return all of the object I do something like:

    Query query ...

4. Named queries returns java.lang.Object instead correct class    forum.hibernate.org

Newbie Joined: Wed Mar 23, 2011 10:57 am Posts: 1 Hello, I've a problem with the return values of named queries: First here's a snippet of my mapping hbm.xml file: Code: ...

5. How to get correct insert order with classes in "triang    forum.hibernate.org

Hello, I'm trying to get the following structure to save correctly in the database: Subscription 1<--->* Book 1<----* Authorisation and Subscription 1<--->* Authorisation which is in effect a triangle. Subscription is the "root" so it uses cascade="all" for both the Book and Authorisation relations. The problem is that Authorisation holds a reference to Book: when I saved a triplet, I got ...

6. Is my HQL query correct ?    forum.hibernate.org

I have the following classes : PolicyDim, ClaimantSnapshotFact and DepartmentDim. PolicyDim - ClaimantSnapshotFact = 1-M ClaimanSnapshotFact - DepartmentDim - 1-1 I want all policies with a policy number of '123456' that have an effective date between x and y and belong to department name 'No Department' Here is the data in the database : - There are 3 policies with policy ...

7. Named Query Not Returning Correct Results    forum.hibernate.org

Hi there Im having a strange problem when trying to execute a Stored Procedure via a named query. The Stored procedure works correctly and returns the correct results from the tables and my hibernate code works correclty i.e. A List of results is returned from the Named Query. My problem is the results that are being returned... The stored procedure returns ...

8. I need help to set a where clause correct.    forum.hibernate.org

select kvotes0_.EIE_EIE_ID as EIE4_1_, kvotes0_.KVO_ID as KVO1_1_, kvotes0_.KVO_ID as KVO1_18_0_, kvotes0_.DRI_DRI_ID as DRI2_18_0_, kvotes0_.AAR_AAR as AAR3_18_0_, kvotes0_.EIE_EIE_ID as EIE4_18_0_, kvotes0_.KVT_KVT_ID as KVT5_18_0_, kvotes0_.TIL_TIL_ID as TIL6_18_0_, kvotes0_.DATO_FRA as DATO7_18_0_, kvotes0_.DATO_TIL as DATO8_18_0_, kvotes0_.KOMMENTAR as KOMMENTAR18_0_, kvotes0_.KVOTE_DISPONIBEL as KVOTE10_18_0_, kvotes0_.KVOTE_TOTAL as KVOTE11_18_0_, kvotes0_.FRITAK_LOK_FOREDLING as FRITAK12_18_0_, kvotes0_.ENDR_DATO as ENDR13_18_0_, kvotes0_.ENDR_BRUKER as ENDR14_18_0_, kvotes0_.DATO_SIST_ENDRET as DATO15_18_0_, kvotes0_.BRUKERIDENT as BRUKERI16_18_0_, kvotes0_.AKTIV as AKTIV18_0_ from MELK.M_KVOTE kvotes0_ ...

9. IS THIS ORDER BY QUERY IS CORRECT?    forum.hibernate.org

Hi all, I have a table Allotment where i have two fields noOfAttempt and one foregn Key User_Id(User table is having UserName and Date Of Birth). Now i have to sort the records in the Allotment table based on the noOfAttempt and age. But Date Of Birth is there in the User Table. How can i solve this problem. Can i ...





10. IS THIS JOIN QUERY CORRECT    forum.hibernate.org

Hi All, Here i am sending some join query it was giving NullPointerException. Please help me out. name and DOB are fields of User table. noOfAttempt and user_id(primary key of User table) is the fields of Allotment Table. i need to sort the records in the allotment table FROM org.bda.api.alt.dto.Allotment allotInfo inner join org.bda.api.alt.dto.User as usr order by allotInfo.noOfAttempt,usr.userDob

11. Projections not returing correct results with the same sql    forum.hibernate.org

Yes, I know... you will say that I have coded something incorrectly. But I am not sure based on the debug statements from Hibernate how this is possible. Basically, I create two criterias with *exactly* the same restrictions. However, on the Count criteria, I set a projection Projectsions.rowCount() to see how many are available. Now here is the kicker. The sql ...

12. setMaxResults() not returning the correct # of rows    forum.hibernate.org

Hi. I am calling setMaxResults on a Criteria instance and I pass it 1000 as the argument. The entity that I am running the query against is a view, and there are 13 rows in the view that I am running the query for. I am only receiving 10 rows back. This is taking place in a test environment, and there ...

13. Criteria with projections not returning correct object type    forum.hibernate.org

Newbie Joined: Sat Mar 29, 2008 6:02 pm Posts: 4 Hi there, I'm new to Criteria and I'm having a bit of trouble trying to generate a query. I have the following object structure where status change events for a given order are stored in a separate history table: Order { customerId, displayableOrderId, List, ... } OrderStatus { description, ... } ...

14. Query by example not retrieving correct result set...    forum.hibernate.org

Author Message meldiscuss Post subject: Query by example not retrieving correct result set... Posted: Sun Jun 01, 2008 4:39 pm Newbie Joined: Sun Jun 01, 2008 3:54 pm Posts: 1 Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.2.6 Java Objects: Award -> AwardRcptRole -> Recipient package com.myco.integration.database.dataobjects; // Generated May 29, 2008 10:29:12 AM ...

15. plz see the hql query ....let me whether its is correct    forum.hibernate.org

select pcb.strEmpId,pcb.nCurrentBasic from PisEmpCurrentBean pcb,AppointmentBean abo where pcb.nStatus=? and pcb.strLocationId=? and pcb.nCurrPayfixationSeqNo is not null and pcb.strObsDate is null"+ " and (getdate() >= (select DATEAdd(mm,6,ab.strJoiningDate) from AppointmentBean ab"+ " where ab.strEmpNo in(select pcbi.strEmpId from PisEmpCurrentBean pcbi where pcbi.nStatus=? and pcbi.strLocationId=? and pcbi.nCurrPayfixationSeqNo is ...