Home > Software engineering >  Cannot resolve column 'id' on @JoinColumn
Cannot resolve column 'id' on @JoinColumn

Time:09-02

I know there is so much posts about this and i'm searching for this problem for hours. I assigned the data sources and got rid of other "Cannot resolve column ..." warnings but these 2 warnings just makes no sense because the referencedColumnName method is referencing the same column types in particular classes on the above lines: enter image description here

Why i'm getting errors on the below 2 lines but not above 2 lines?

CarBrand entity:

package com.sbm.insurance.entities;

import lombok.*;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.util.List;

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(
        uniqueConstraints = @UniqueConstraint(
                name = "carBrand",
                columnNames = "carBrand"
        )
)
public class CarBrands {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank(message = "Car Brand can't be null or empty")
    private String carBrand;

    @Min(1)
    @Max(999999)
    private float carBrandMultiplier;

    @OneToMany(
            mappedBy = "brand",
            cascade = CascadeType.REMOVE,
            fetch = FetchType.LAZY
    )
    private List<Car> car;

}

CodePudding user response:

I would assume because classes Account and Proposal have a field called id, but CarBrands and CarTypes don't.

CodePudding user response:

Can you also paste CarBrands entity ?

  • Related