In my entities classes I use to define the temporal fields as follows: In my oracle DB the columns mapped by those fields are of type TIMESTAMP. What are the implications of this configurations: Are my dates implicitily UTC dates ? Does it mean I have to be careful on handling by myself Daylight saving time i…
Tag: jpa
How to specify UTC timezone for Spring Boot JPA Timestamp
Environment Spring Boot Starter Data JPA 1.4.2 Eclipselink 2.5.0 Postgresql 9.4.1211.jre7 Problem I am building a Spring Boot microservice that shares a Postgresql database with a different service. The database gets initialized externally (out of our control) and the datetime column type used by the other se…
Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
When I compile my spring project, I got the following error. Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed I am using STS Eclipse and MySql D…
How to use Postgres JSONB datatype with JPA?
Im not finding a way to map the JSON and JSONB datatypes from PostgreSQL using JPA (EclipseLink). Is some one using this datatypes with JPA and can give me some working examples? Answer All the answers helped me to reach the final solution that is ready for JPA and not EclipseLink or Hibernate specifically.
JPA update based on column name
I want to update value to a specific column entered by the user. Here are my codes, do anyone how to modify it to correct one? Answer You should go for criteria builder query for your case… if you are using JPA 2.1.. here is something you can should do
JPA Criteria multiselect with fetch
I have following model: Now I would like to query only columns: id, name, shortName and mentor which referes to User entity (not complete entity, because it has many other properties and I would like to have best performance). When I write query: I have following exception: Query before exception: I know that…
How to set initial value for @Id @GeneratedValue in Spring JPA for MySQL?
I can not figure out how to set the initial value for the @GenerateValue @Id. I have tried using GenerationType.SEQUENCE but that is not allowed in MySQL. How can I set the initial value to be used for the @GenerateValue? Using both AUTO and TABLE I can still not get the initial value to start at anything but…
How to find cortege with OneToMany relation in Spring Data JPA
I use Spring Data JPA and have two entities: and And repository: I need to find available vehicles, which not booked by time. How can I do this? Answer I would go for something like: BTW I think that you might wanna try to change FetchType from EAGER to LAZY for bookingTime and then use join fetch in select q…
`Type cannot be null` exception when trying to run out Stored Procedure using Spring Data JPA
I am trying to invoke a Stored Procedure whose signature looks like the following: I am using Spring-Data JPA and have tried a number of different variants, but all of them follow more or less the following pattern. My entity model is decorated as follows: Then I have my repository which looks like the follow…
How to create a sequence in JPA without creating it directly in the database
I am doing a service that gets data from a source and fetches them into my Database by using JPA. The id is generated by using sequence. I have created the sequence on my DB by using this command: However, I don’t know how to create the sequence directly from my code. Can anyone please help me to figure…