Skip to content
Advertisement

Tag: jpa

How do I cast JPA criteria Expression to long java type

This code has not compile error but at run time gets this error: Cannot cast from Expression to int I tried using String: This also gets error: ERROR: For input string: “org.hibernate.query.criteria.internal.path.SingularAttributePath@2ed2d35d”; nested exception is java.lang.NumberFormatException: For input string: “org.hibernate.query.criteria.internal.path.SingularAttributePath@2ed2d35d” Answer In your first error, you are mixing LocalDateTime.now().minusDays with the Expression root.get(“person”).get(“birthDay”).as(Long.class), and it is not possible. The error

A bean named ‘entityManagerFactory’ that could not be found

I’m pretty new to Hibernate/JPA. Running the application, I’m getting this error: The main class (I use @EnableJpaRepositories to let Spring find the repository in other package): My main entity class: A repository: A properties file: Maven dependencies: What should I do here? Answer I solved this adding the following dependency instead of spring-data-jpa: After that, I got this exception:

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

Spring, Jpa : One To Many Error when the list contains values

I want to return a Profile Object in JSON containing a list of login details associated with a social network. Everything works correctly when the “reseaux_sociaux” table is empty. For my status table I get my statuses in JSON format in my Profile object. However, when “reseaux_sociaux” contains values then I get the error below and my Profile object in

Advertisement