Skip to content

Tag: jpa

Hibernate: How to distinguish two uni-directional relationship and one bi-directional relationship?

in this answer, the author said: Take an example of two entities mapped without declaring a owning side: From a OO point of view this mapping defines not one bi-directional relation, but two separate uni-directional relations. 1.My first question is: Why it is not a bi-directional relation? Docs Oracle: In a bidirectional relationship, each entity has a relationship field or

JPQL issue updating records

Trying to update a record in a database but getting this error: Code below is responsible for inserting it Im not sure if there is a type issue with propId being a Long or if i have written the SQL paths wrong or both. Answer You’re trying to execute an SQL query as JPQL. There are a couple options to

Criteria API join with filter

So I am trying to replace the following native SQL with JPA Criteria Api: or The entities look a bit like this: I implemented a I can use together with a JpaSpecificationExecutor like: and But I only get one side of the join/select like: when I do: How do I add the table to the select here? So the

Update statement is no query?

How do I define the update statement in the orm.xml. I have it as a named-query and everything works, but my teacher said that an update statement isn’t a query. I have tried a native query, but that wasn’t working. ORM-Type: Update Statement: Answer The term “query” is used rather ambiguously. Some people interpret it literally as “asking for information”,

JPA repository Boolean Query – return null pointer exception

I have Java springBoot project With repository that included boolean custom query. but the system run to null pointer exception apart from return “false”. this is the query: I called the method: and this is the error: Answer Your query is designed to return whatever entity (called CustomersVsCoupons from now on) is mapped to the table customer_vs_coupons, not a Boolean.