Hi I am struggling to find what is wrong in my code I have searched and tried to find the answers to it, I also checked my database to see if my naming conventions matched the one I have in my models and also double checked if the @Column in my BreakDown model matched the @JoinColumn in my finance model and it matches. I would appreciate it if someone could help me here is the code
Repository
@Repository
public interface BreakDownRepository extends JpaRepository<BreakDown, Long>{
@Query(value = "select * from break_down as b left join finance as f "
+ "ON b.finance_id = f.finance_id where b.finance_id = :financeId",
nativeQuery = true)
List<BreakDown> findByFinanceId(@Param("financeId") Long financeId);
}
Finance model
@Entity
public class Finance implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "finance_id")
private Long financeId;
@Column(name = "assets")
private int assets;
@Column(name = "profit")
private int profit;
@Column(name = "loss")
private int loss;
@Column(name = "revenue")
private int revenue;
@Column(name = "cost")
private int cost;
@Column(name = "f_date")
private Date fDate;
@Column(name = "currency")
private String currency;
@OneToOne
@JoinColumn(name = "emp_id")
private Employee employee;
@OneToOne
@JoinColumn(name = "customer_id")
private Customer customer;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "break_down_id")
private List<BreakDown> breakDown;
//setters getters
BreakDown model
@Entity
public class BreakDown implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "break_down_id")
private Long breakDownId;
@Column(name = "item")
private String productName;
@Column(name = "cost")
private float price;
private int quantity;
private float total;
@ManyToOne
@JsonBackReference
private Finance finance;
//setters getters
Error stack trace
2021-05-15T04:20:21.606644+00:00 app[web.1]: org.postgresql.util.PSQLException: The column name
finance_finance_id was not found in this ResultSet.
Thank you in advance all answers are appreciated