Questions tagged [jpql]

The Java Persistence Query Language (JPQL) is a platform-independent object-oriented query language defined as part of the Java Persistence API specification.

The Java Persistence query language (JPQL) is used to define searches against persistent entities independent of the mechanism used to store those entities. As such, JPQL is "portable", and not constrained to any particular data store. The Java Persistence query language is an extension of the Enterprise JavaBeans query language (EJB QL), adding operations such as bulk deletes and updates, join operations, aggregates, projections and subqueries.

3498 questions
1
vote
1 answer

JPQL join condition in linked Entity class

I'm using the following SQL to join employees, user_projects and project_master SELECT DISTINCT usr.user_number, emp.emp_name FROM employees emp LEFT JOIN user_projects usr ON (emp.user_number =…
Jacob
  • 14,463
  • 65
  • 207
  • 320
1
vote
0 answers

Converting an existing SQL statment to a JPQL statement

I have problem with converting an existing SQL statment to a JPQL statement. SQL statement is: select SeatsID from cinema.seats a where a.SeatsID not in (select SeatID FROM cinema.reservation_seats s, cinema.reservation r where…
1
vote
0 answers

What does MAX aggregation on an entity identification variable do?

I'm trying to migrate old code that uses JPA 1.0 and Hibernate 3.3 (yes, it's really old) to a different (non-SQL) data API. One of the queries looks something like this: SELECT tx.transactionId, MAX(tx), SUM(tx.amount) FROM Transaction tx WHERE…
Peter Halverson
  • 380
  • 2
  • 12
1
vote
0 answers

GROUP BY clause in JPQL

I use Hibernate as persistence provider, database is Oracle XE. Here is a JP QL query: SELECT news, COUNT(comments) FROM News news JOIN news.comments comments GROUP BY news News is in one-to-many relation with Comments. When i try to use it,…
Aliaxander
  • 2,547
  • 4
  • 20
  • 45
1
vote
1 answer

Get List of Strings using JPQL

I'm new to Java and still learning, please keep that in mind when answering. So I want to get a list of strings based on data from a MySQL database using JPQL. More specifically I'm trying to get all unique years from a certain column in a certain…
Wouter
  • 430
  • 2
  • 5
  • 13
1
vote
1 answer

JPQL createNativeQuery with join failing

I'm joining 2 entities with a foreign key relationship in the db, but not in the code (saving the why for another question): em.createNativeQuery("SELECT u.* FROM user u JOIN user_community_organization uco ON " + "u.user_id =…
gebuh
  • 797
  • 14
  • 40
1
vote
1 answer

JPQL query causing ORA-00907: missing right parenthesis. How to fix?

I am trying to run the following query, using Oracle 10: select intel from Intel intel where intel in (select intel from Intel intel where intel.city.name = 'Rome' order by intel.city.name asc) However, I am getting "ORA-00907: missing right…
Michael Tontchev
  • 909
  • 8
  • 23
1
vote
1 answer

JPQL to Criteria

I have following classes: @Embeddable Class A // (with field String x); Class B // (with field @Embedded A a) Class C // (with field @OneToOne B b); I would like to create method getAllByXs(List xs) using criteria to get all C entries where…
user123454321
  • 1,028
  • 8
  • 26
1
vote
4 answers

Building complex SQL query when one value depend on other value in query

Database: Table_Sensor: sensor_id, sensor_name Table_Sensor_Detection: sensor_id azimuth (azimuth from specific sensor) Users have the possibility to enter multiple Sensors, so I have defined Set < Integer> sensorsSet. Users also…
frane
  • 65
  • 1
  • 7
1
vote
0 answers

jpql replaces 1 with?

Trying to find a way around an integer being replaced with "?". SQL that works as expected: select max(m.ticket_num) **+ 1** from mytable m where current date = DATE(m.create_ts) JPQL: @NamedQuery( name = "Orders.findNewTicketNum", …
DanielGA
  • 11
  • 3
1
vote
1 answer

Parsing of IN-Clause in JPQL typedquery

I am trying execute query which were working fine in JPA but these are not working on Open JPA, have you any idea? String iNString; try { String query = "Delete FROM Table1o WHERE o.Pk1 IN('"+ iNString+ "') and o.countryCode = '"+…
1
vote
1 answer

Initializing many-to-many association in Hibernate with join table

I have a Company entity that I fetch with a JPQL query with Hibernate. The entity has a many-to-many association with a Keyword entity. Since the join table has an additional column is_active, this table has been mapped to a CompanyKeyword entity.…
ba0708
  • 10,180
  • 13
  • 67
  • 99
1
vote
2 answers

Kundera cast String "1" to Integer 1 in queries

I got next exception: Caused by: com.impetus.kundera.KunderaException: com.datastax.driver.core.exceptions.InvalidQueryException: Invalid INTEGER constant (1) for promo_code_id of type ascii at…
Dolzhenok
  • 78
  • 6
1
vote
1 answer

Hibernate using OneToOne

I have two tables tab1 { col1 (PK), col2, col3 } tab2 { col1, col2(PK), col3 } I am using Hibernate annotation for joining using "OneToOne" I have the below Hibernate class for tab1 class tab1 { @OneToOne @JoinColumn(name = "col2",…
Soft
  • 1,796
  • 5
  • 19
  • 30
1
vote
2 answers

JPA use IN clause with objects

I am facing a problem usign JPA, and more specifically using a IN clause. The best way is, I think, to show you my code : @NamedQuery(name = "Commande.findCustom", query = "SELECT DISTINCT [myFields] " + "FROM Commande c WHERE " …
user4676340
1 2 3
99
100