Java 栏「;工厂标识;找不到

Java 栏「;工厂标识;找不到,java,spring-mvc,Java,Spring Mvc,我有两个类,我试图在它们之间建立关联,但当我试图对它们运行此查询时 insert into purchase_order (id, plant_id, start_date, end_date, cost) values (1, 2, '2016-03-22', '2016-03-24', 600); 我面临以下错误 Column "PLANT_ID" not found in sql statement 这是PurchaseOrder类 @Entity @Data public

我有两个类,我试图在它们之间建立关联,但当我试图对它们运行此查询时

insert into purchase_order (id, plant_id, start_date, end_date, cost)
    values (1, 2, '2016-03-22', '2016-03-24', 600);
我面临以下错误

 Column "PLANT_ID" not found in sql statement
这是PurchaseOrder类

@Entity
@Data
public class PurchaseOrder {
      @Id
      @GeneratedValue
      Long id;

      @OneToOne
      PlantInventoryEntry plant_id;

      LocalDate issueDate;
      LocalDate paymentSchedule;
      @Column(precision=8,scale=2)
      BigDecimal cost;

      @Enumerated(EnumType.STRING)
      POStatus status;
      LocalDate startDate;
      LocalDate endDate;
    }
这是它的jpa界面:

@Repository
public interface PlantRepository extends JpaRepository<PurchaseOrder, Long>{

}
及其
jpa

 @Repository
public interface PurchaseOrderRepository  extends JpaRepository<PlantInventoryEntry, Long>{

}
@存储库
公共接口PurchaseOrderRepository扩展了JpaRepository{
}
如您所见,我的采购订单表中有工厂id, 但是为什么它不起作用呢

检查您的数据库

采购订单
没有列
工厂ID

有时问题也可能与大小写有关,这取决于数据库的配置,因此如果列plant_id存在,请检查是否具有相同的大小写


此问题与JPA无关,您也可以让它直接在标准客户端数据库中尝试查询。

这意味着数据库中的表没有名为
PLANT\u ID的列。
。它与Java代码无关,但在SpringMVC中,我使用Java代码创建表。对吗?您可能使用没有
PLANT\u ID
的早期版本创建了表?在数据库中查看表的外观。如有必要,请删除该表并重新创建它。尽管数据库有列
PLANT\u ID
,但JPA没有(正确的)映射。它应该是这样的:
@OneToOne(mappedBy=“plantId”)plantinventory条目plantinventory条目 @Repository
public interface PurchaseOrderRepository  extends JpaRepository<PlantInventoryEntry, Long>{

}