Модель / сущность 1: PriceListItemTest.Java
package com.Pricing.Pricing_App.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonPropertyOrder({"pricingUOMCode","lineTypeCode","primaryPricingUOMFlag","priceListId","itemId","priceListItemId"})
@Entity
@Table(name = "QP_PRICE_LIST_ITEMS")
public class PriceListItemTest implements Serializable{
// @Id
@Column(name = "price_list_item_id")
private String priceListItemId;
@Column(name = "pricing_uom_code")
private String pricingUOMCode;
@Column(name = "line_type_code")
private String lineTypeCode;
@Column(name = "primary_pricing_uom_flag")
private String primaryPricingUOMFlag;
@Id
@Column(name = "item_id")
private String itemId;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "item_id", referencedColumnName = "inventory_item_id")
// @JoinColumn(name = "inventory_item_id", referencedColumnName = "item_id")
private List<ItemDetailTest> itemDetailsTest;
public List<ItemDetailTest> getItemDetailsTest() {
return itemDetailsTest;
}
public void setItemDetailsTest(List<ItemDetailTest> itemDetailsTest) {
this.itemDetailsTest = itemDetailsTest;
}
public String getPricingUOMCode() {
return pricingUOMCode;
}
public void setPricingUOMCode(String pricingUOMCode) {
this.pricingUOMCode = pricingUOMCode;
}
public String getLineTypeCode() {
return lineTypeCode;
}
public void setLineTypeCode(String lineTypeCode) {
this.lineTypeCode = lineTypeCode;
}
public String getPrimaryPricingUOMFlag() {
return primaryPricingUOMFlag;
}
public void setPrimaryPricingUOMFlag(String primaryPricingUOMFlag) {
this.primaryPricingUOMFlag = primaryPricingUOMFlag;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getPriceListItemId() {
return priceListItemId;
}
public void setPriceListItemId(String priceListItemId) {
this.priceListItemId = priceListItemId;
}
}
Модель / сущность 2: ItemDetailTest.java
package com.Pricing.Pricing_App.model;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonPropertyOrder({"itemNumber","inventoryItemId","organizationId"})
@Entity
@Table(name = "egp_system_items_b")
public class ItemDetailTest implements Serializable {
@Id
@Column(name = "inventory_item_id")
private String inventoryItemId;
@Column(name = "item_number")
private String itemNumber;
@Column(name = "organization_id")
private String organizationId;
public String getItemNumber() {
return itemNumber;
}
public void setItemNumber(String itemNumber) {
this.itemNumber = itemNumber;
}
public String getInventoryItemId() {
return inventoryItemId;
}
public void setInventoryItemId(String inventoryItemId) {
this.inventoryItemId = inventoryItemId;
}
public String getOrganizationId() {
return organizationId;
}
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}
}
Я не могу запустить локальный сервер и получаю сообщение об ошибке ниже:
Exception encountered during context initialization - cancelling refresh
attempt: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'entityManagerFactory' defined in class path
resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
: Invocation of init method failed; nested exception is
org.hibernate.AnnotationException: Unable to map collection
com.Pricing.Pricing_App.model.PriceListItemTest.itemDetailsTest
Я думаю, что в отображении есть какая-то проблема, может кто-нибудь помочь с этим?Если я изменю отношение к OneToOne, оно будет работать нормально.Но ожидание, чтобы сделать это onetomany