0
我知道这个问题已被问到several times但他们没有帮助我。 我有以下测试:org.hibernate.MappingException:无法确定类型:在表格中:for列:[org.hibernate.mapping.Column(plant)
public class PlantCatalogTests {
@Autowired
PlantInventoryEntryRepository plantRepo;
@Test
public void queryPlantCatalog() {
assertThat(plantRepo.count(), is(14l));
}
,这里是PlantInventoryEntryRepository
@Repository
public interface PlantInventoryEntryRepository extends JpaRepository<PlantInventoryEntry, Long> {}
正如你看到的,这个仓库是基于类PlantInventoryEntry
@Entity
@Data
public class PlantInventoryEntry {
@Id
@GeneratedValue
Long id;
@OneToOne
PurchaseOrder plant_id;
String name;
String description;
String price;
}
PurchaseOrder的是另一个类,我有它的一个实例在我的PlantInventoryEntry类的属性:
@Entity
@Data
public class PurchaseOrder {
@Id
@GeneratedValue
Long id;
List<PlantReservation> reservations;
PlantInventoryEntry plant;
LocalDate issueDate;
LocalDate paymentSchedule;
@Column(precision=8,scale=2)
BigDecimal total;
@Enumerated(EnumType.STRING)
POStatus status;
LocalDate startDate;
LocalDate endDate;
}
我的主要问题是,当我运行我的测试,我面对这个错误:
org.hibernate.MappingException: Could not determine type for: com.example.models.PlantInventoryEntry, at table: purchase_order, for columns: [org.hibernate.mapping.Column(plant)
我如何解决这个错误?
您能否在**语句中描述** mappedby =“order”** ** OneToMany(mappedBy =“order”)**? –
该字段是否映射到两个对象中?如果是这样,你需要像上面那样指定mappedBy属性。如果它唯一映射在PurchaseOrder中,则可以省略它。有关更多信息,请参阅文档https://docs.oracle.com/javaee/6/api/javax/persistence/OneToMany.html – hyness