Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
1 answer
24 views

Entity Inheritance and query filtering

I'm trying to achieve a very basic from SQL point of view operation but using Spring Boot and JPA This is my Java data model: @MappedSuperclass public abstract class BaseEntity { @Id @...
Witek's user avatar
  • 55
0 votes
0 answers
29 views

Why does Blaze-Persistence project count queries for pagination despite potential performance issues?

I'm using Blaze-Persistence and noticed that its offset pagination feature projects the count query as follows( concisely reduced ): select *, (select count(*) from Entity) from Entity e inner join ...
InJun C's user avatar
1 vote
0 answers
72 views

Join parent with children and children with grandchildren in a single query

I am learning Spring Data JPA. I want to implement this query in it: select * from p left join c on p.p_id = c.p_id left join g on c.c_id = g.c_id; I have three tables, p, c and g. These are ...
Sidharth Bajpai's user avatar
-1 votes
0 answers
15 views

Parameterize jsonb specfic key with Spring Jpa

There is a list having once column jsonb type . { "quoteId":2024, "quoteName":"EDE", "quoteDetails" :[ "id":3156, "metadata":[ "code&...
Rajesh K's user avatar
1 vote
1 answer
109 views

Spring Data JPA/Hibernate: JPQL constructor expressions- difference between using "new(..)" and not using it

I am using JPQL and projecting the specific returned fields into a different Class than the Entity. I can achieve it using at least the following 2 ways in JPQL with EntityManger (em in code):- @Test ...
Sidharth Bajpai's user avatar
0 votes
1 answer
39 views

Anyone can translate this JPQL to mySQL

@Query("SELECT u FROM User u LEFT JOIN FETCH u.roles WHERE u.email = :email") Optional<User> findByEmailWithRoles(@Param("email") String email); I like to use mysql but this ...
Shubham kumar's user avatar
-1 votes
1 answer
35 views

Why does one delete statement cascade, but not the other?

In my Spring Boot app, I have a table message which has a child table message_recipient i.e. the latter holds a foreign key to the former. These are both mapped to domain classes using JPA. I've ...
Dónal's user avatar
  • 187k
0 votes
0 answers
20 views

JPQL ignores Boolean param of joined entity field which is @Embedded

I have written JPQL query in repo to retrieve quiz with child questions which are not deleted. Deletion data is kept in @Embedded field Removal on entity. However the repository method keeps returning ...
Miłosz's user avatar
  • 17
0 votes
0 answers
18 views

JPA OneToMany JoinColumn returning unrelated children

my first real-life experience with JPA. So please forgive naiveness! I have two 1-to-n related DB tables and I need a read-only access through JPA to them. I have realized the JPQA query like below ...
ffxx68's user avatar
  • 93
0 votes
0 answers
69 views

Spring Boot 3.x.x, Left Join with condition stopped working correctly

I have custom query in jpa repository: @Repository public interface UserRepository extends JpaRepository<User, Long> { @Query(""" select user ...
Denis Bezrukov's user avatar
0 votes
0 answers
33 views

JPA Query with NOT LIKE doesn't work to filter ips

I am working with a JPQL query to filter some gateways ips ending with 1 (the column in the database is of type INET but on the entity is of type String): ...AND concat(c.ip,'') not LIKE '%.1' THe ...
Ana M's user avatar
  • 1
0 votes
1 answer
66 views

What string can be used in JPQL order by to cause SQL injection?

Consider code similar to this: String orderBy = getParameter("orderBy"); String orderDir = getOrderDir(); // returns "asc" or "desc" String query = "select u from ...
Macok's user avatar
  • 9
0 votes
0 answers
17 views

How to query the inverse relationship of a ManyToMany in JPQL?

I have 3 entities that have the following relationships (all ManyToMany): EquipmentMaster <=> ComponentMaster <=> CanMaster EquipmentMaster <=> CanMaster Classes (getters & ...
Musa Kapan's user avatar
0 votes
1 answer
23 views

Use JPQL or SQL to SELECT items _not_ in the database from a supplied set in the query parameters

I have an interesting problem, I need to figure out which files I have not processed. I have an object called ReturnFile(return_files) that stores the ones I've processed. I'd like to issue a query ...
Jonathan S. Fisher's user avatar
0 votes
1 answer
55 views

How to join tables efficiently?

In Java, with JPA and EclipseLink. Lets say I have 3 tables: Supplier, Order and Customer I want to get all customers that have an order by said supplier. Say suppliers and customers are not directly ...
deantre.s's user avatar

15 30 50 per page
1
2 3 4 5
136