org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Table [basket] contains physical column name [user_id] referred to by multiple logical column names: [user_id], [userId]
I'm having this problem and this is my class:
package sukhrob.project.firstproject.entities;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import sukhrob.project.firstproject.entities.enums.BasketTypeEnum;
import sukhrob.project.firstproject.entities.template.AbsEntity;
import java.util.UUID;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Where(clause = "deleted=false")
@SQLDelete(sql = "update basket set deleted=true where id=?")
@Entity(name = "basket")
public class Basket extends AbsEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", updatable = false, insertable = false)
private User user;
@Column(name = "user_id")
private UUID userId;
@Enumerated(value = EnumType.STRING)
private BasketTypeEnum basketType;
private String description;
}
i'm having this error. can someone help with this?
Remove the column userId
public class Basket extends AbsEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", updatable = false, insertable = false)
private User user;
@Enumerated(value = EnumType.STRING)
private BasketTypeEnum basketType;
private String description;
}
This will be automatically generate using the @JoinColumn
annotation