openjpa « Query « JPA Q&A


I'm having an issue with a SELECT NEW query.

Query q = em.createQuery(
           "SELECT NEW com.bcbst.odstats.ejb.RangeStats(a.folderName, SUM(a.hits)) " +  

2. Help with JPQL query

I have to query a Message that is in a provided list of Groups and has not been Deactivated by the current user. Here is some pseudo code to illustrate the ...

3. sql query with space in the value

How do I write where clause where the value has spaces: Actually I am using openJPA and I have to set parameter. The value i will be setting has a space, eg: String somevalue="firstname ...

4. select from two tables using JPQL

I m using JPQL to retrieve data. I can get data using the statement

List persons = null;
persons = em.createQuery("select p.albumName from PhotoAlbum p , Roleuser r 
where r = p.userId and ...

5. Can we assign custom Query Hints to JPA NamedQueries

We are required to append query numbers to each and every query our application executes. EX: SELECT * FROM ... WHERE ... QUERYNO 123456; OpenJPA supports query hints, but only for ...

6. OpenJPA: how to construct a GROUP BY query with a group count

In JPQL I want to construct the equivalent query to this:

select *, count(*) as finger_count from page_delta_summary 
where delta_history_id = ? and change_type = ? group by fingerprint;
where fingerprint is a ...

7. Slow Performing OpenJPA Query

I have the following query method that has slow performance:

public Map<String, Long> getFeatureCounts() {

    StopWatch timer = new StopWatch();
    Map<String, Long> ...

8. why is OpenJPA 2.1 throwing ArgumentException when using a critera query and equal(x,object)?

Why does this work:

    builder = em.getCriteriaBuilder();
    CriteriaQuery<ClaimVersion> criteriaClaimVersion = builder.createQuery(ClaimVersion.class);
    rootClaimVersion = criteriaClaimVersion.from(ClaimVersion.class);

9. How to write named native subqueries in JPA?

I was given a task to write a named native subquery like

select c.comp_name from company c where c.cid = (select cid from com_usr_rel where uid=1100)
The entities are company

public class Company implements Serializable ...

10. Subqueries in JPA is not working with OpenJPA

Does JPA support subqueries in the select part of the main query. For example : SELECT record1.txnId, record1.accessTime, (SELECT record2.accessTime FROM Metering record2 WHERE record2.txnId=record1.txnId AND record2.action='END') FROM Metering record1 WHERE record1.action='START' The above query is properly working with Hibernate implementation. But when i use OpenJPA implementation instead of Hibernate implementation it is giving the following error: org.springframework.dao.InvalidDataAccessApiUsageException: Encountered "(" at ...