Hi I am new to Spring Boot. I try to connect to Oracle and list related records. My code worked in a stub environment, that is without connecting to a db. When I tried to connec
It seems that the problem is following:
Because of this property:
spring.jpa.properties.hibernate.hbm2ddl.auto = update
And the fact that the Posts entity has been changed to reference the User, Hibernate tries to add a foreign key constraint:
alter table posts add constraint FK6xvn0811tkyo3nfjk2xvqx6ns foreign key (author_id) references users
But gets this error:
ORA-02268: referenced table does not have a primary key
Not sure why hibernate does not add a primary key to this table as the @Id annotation is clearly there.
Try to add a primary key constraint manually to the Users.id column:
ALTER TABLE users
ADD CONSTRAINT users_pk PRIMARY KEY (id);
Update
The problem might with the Post.data mapping as you are using it in the order by clause.
The doc says:
This annotation must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar. It may only be specified for fields or properties of these types.
As you are using java.util.Date, then you need to add this:
@Temporal(TemporalType.DATE)
private Date date = new Date();