I have MySQL table with readonly access oc_category
(table from Opencart).
With the next records:
id | parent_id | Category
------------------------------
1 | 0 | TOPCategory1
2 | 0 | TOPCategory2
3 | 1 | Category1
4 | 1 | Category2
But this table doesn't have record with id
- 0
, but have parent_id
with 0
- this mean that this category doesn't have parent category.
I have entity:
@Entity
@Table(name = "oc_category")
public class Category {
@Id
@Column(name = "category_id")
private Integer categoryId;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "parent_id")
private Category parent;
@OneToMany(mappedBy = "parent")
private List<Category> childCategory = new ArrayList<>();
// other fields, constructor, getters and setters.
}
When I try to get records I recieved error that I don't have record with id
0
. :(
"Unable to find opencart.Category with id 0; nested exception is javax.persistence.EntityNotFoundException: Unable to find opencart.Category with id 0"
Please help resolve this issue.