Владелец Entity: PriceListItemTest.java
@JsonPropertyOrder({"pricingUOMCode","lineTypeCode","primaryPricingUOMFlag","priceListId","itemId","priceListItemId"})
@Entity
@Table(name = "QP_PRICE_LIST_ITEMS")
public class PriceListItemTest implements Serializable{
@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(mappedBy = "priceListItemsTest", cascade = CascadeType.ALL)
private List<ItemDetailTest> itemDetailsTest;
// getters and setters
}
и Entity2: ItemDetailTest.java
@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;
// To be used for bidirectional
@ManyToOne//(fetch = FetchType.LAZY)
private PriceListItemTest priceListItemsTest;
// getters and setters
}
RestController возвращает ошибку при получении результата JSON.
{
"timestamp": "2018-10-23T14:05:26.248+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Could not write JSON: could not extract ResultSet; nested exception is com.fasterxml.jackson.databind.JsonMappingException: could not extract ResultSet (through reference chain: java.util.ArrayList[0]->com.Pricing.Pricing_App.model.PriceListItemTest[\"itemDetailsTest\"])",
"path": "/getByItemIdTest"
}
Возможно, сопоставление oneTomany неверно.
Работает нормально, если имеет сопоставление oneToone, но сталкивается с проблемой OneToMany.Может кто-нибудь, пожалуйста, помогите мне с ошибкой?
Редактировать: Контроллер:
@RestController
public class PriceListItemControllerTest {
@Autowired
private PriceListItemRepositoryTest priceListItemRepositoryTest;
@GetMapping(value="/getByItemIdTest")
public List<PriceListItemTest> getByItemIdTest(@RequestParam("itemId") String itemId) {
return priceListItemRepositoryTest.findByItemId(itemId);
}
}