ejb « Query « JPA Q&A

1. What is a good design for a query "layer" for Java JPA    stackoverflow.com

In JPA the Entities are nice annotated Plain Old Java Objects. But I have not found a good way to interact with them and the database. In my current app, my basic ...

2. Ejb-QL DISTINCT ON    stackoverflow.com

Is it possible to use PostgreSQL-like DISTINCT ON in EJB-QL query? What i need to do is to fetch from db records that are distinct on 3 of 10 columns.

3. JPQL createQuery throws illegalArgumentException    stackoverflow.com

The following simple code throws exception:

entityManager.createQuery("SELECT c FROM Customer c");
But if I write
entityManager.createNativeQuery("SELECT c.* FROM Customer c", Customer.class)
then it works without any error. What might be wrong? I use GlassFish ...

4. EJB3 Query + in clause    stackoverflow.com

I need to use an IN clause like the following SQL

SELECT * FROM tableA WHERE colA in (1, 2,3)
How can i do this in EJBQL? i've tryed the following, which obviously ...

5. Why does query caching with Hibernate make the query ten times slower?    stackoverflow.com

I'm currently experimenting with EJB3 as a prestudy for a major project at work. One of the things I'm looking into is query caching. I've made a very simple domain model ...

6. Criteria queries in EJB 3    stackoverflow.com

Can I use Criteria queries with EJB3 entities? If so, how can I combine them with EntityManager?

7. JPA : optimize EJB-QL query involving large many-to-many join table    stackoverflow.com

I'm using Hibernate Entity Manager 3.4.0.GA with Spring 2.5.6 and MySql 5.1. I have a use case where an entity called Artifact has a reflexive many-to-many relation with itself, and the join ...

8. use DISTINCT ON Ejb-QL    stackoverflow.com

is it possible to use PostgreSQL-like DISTINCT ON in EJB using named query? o.fromDate,o.empLeaveMasterId,o.employeeInfoId, o.leavePurposeId ,o.toDate,o.createdByUserId,o.createDate,o.lastModifiedUserId,o.lastModifiedDate,o.isSystemRecord The field describe above is my entity bean field and I want to get fromDate wise ...

9. conflict select with EJB3    stackoverflow.com

Today i have new problem with JPA/EJB3. I have 2 table User and Group with mapping OneToMany (Group One - User Many) When I use select statement in EJB, for example:

@NamedQuery(name = "Iuser.findAll", ...

10. EJB3, JPA error with More than one result was returned from Query.getSingleResult()    stackoverflow.com

i have new problem with JPA in EJB3 my stacktrace are:

Caused by: javax.persistence.NonUniqueResultException: More than one result was returned from Query.getSingleResult()
        at org.eclipse.persistence.internal.jpa.EJBQueryImpl.throwNonUniqueResultException(EJBQueryImpl.java:1207)

11. How to select only month in JPA    stackoverflow.com

i have trouble with select only month or year in JPA in mysql i write statement follow:

select * from table where Month(date) = 12 ;
and in entity bean i write follow:
select t ...

12. Store and refresh object with EJB 2.0 and JPA (Toplink) problem    stackoverflow.com

From my client app I want to call store and refresh in one EJB method instead of two calls to two methods. I made an EJB method, made it call the ...

13. Table will not UPDATE sometimes through a Hibernate native query    stackoverflow.com

I have an entity, let's call it X. (the entity has a @Id id). The entity is mapped to a table, let's call it: X_TABLE. It also contains a

@JoinColumn(name = "JOIN_COLUMN")
YClass joinColumn;//another ...

14. Date Query in JPA    stackoverflow.com

How To write Query in JPA base on month selection. E.g. There is column effective_date in the table which contains dates values shown below records

1 May 
1 Jun
2 July 
1 Aug
and if ...

15. Hibernate Criteria equivalent for IN clause in Subqueries?    stackoverflow.com

I would like to translate a query like this one:

FROM Entity_1 obj
WHERE obj IN (FROM Entity2) OR 
      obj IN (FROM Entity3)
To hibernate Criteria form, and ...

16. How to build JPQL queries when parameters are dynamic?    stackoverflow.com

I wonder if there is a good solution to build a JPQL query (my query is too "expressive" and i cannot use Criteria) based on a filter. Something like:

query = "Select from ...

17. Problem with EJB Named Query and JPQL argument    forums.netbeans.org

Hi All, Please I have been trying to execute an ejb query for finding an item. I have an entity called Product which contains all the properties such as make, model etc. Also I have created the productfacade class which uses this ejb query public List findByModel() { return em.createQuery("SELECT p FROM Product p WHERE p.model = :model").getResultList(); } to try ...

18. EJB3/Hibernate: how to use sum/group by in a native query    coderanch.com

Hi I have been googling for some days, but without result I have one table whose fields are DATE (DATE) PLACE (INTEGER) AMOUNT (INTEGER) In plain sql, I need SELECT date,place,sum(amount) FROM table GROUP BY date,place ORDER BY place,date; I tried to make a native query List l = em.createNativeQuery(zeQuery).getResultList(); This makes a list of Object whose size is the number ...

19. EJB, EntityMangaer query with count problem.    forum.hibernate.org

Hi all. i've some problem. i've a method inside my ejb. (try to find out the similar item, the value is setted static to 1 for the trials) Code: public List findSimilarItem(Item item) { ArrayList result = new ArrayList(); Long resulto ...