I have table item_image:
create table item_image
(
item_id bigint not null
constraint item_image_pk
primary key
constraint item_image_item_fk
references item,
location varchar(1000) not null,
path varchar(1000) not null,
file_name varchar(200) not null
);
And mapped it to entity:
@Entity
@Table(name = "item_image", schema = "public")
public class ItemImageEntity implements Serializable {
@Id
@OneToOne
@JoinColumn(name = "item_id")
private ItemEntity item;
private String location;
private String path;
private String fileName;
// getters and setters
}
My item entity has:
@OneToOne(mappedBy = "item")
private ItemImageEntity profileImage;
in it, the postgress table does not contain refference to this item_image, only vice versa.
When i try to run the app i get:
@EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: This class [ItemImageEntity] does not define an IdClass
Why do i need to define IdClass and How? Since i have only 1 primary key.
Thanks for help!