Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Recursive Parent Child relationship in JPA

@Entity
@Table(name = "OBJECTCATEGORY")

public class ObjectCategory implements Serializable {

	@Id
	private String categoryId;

	private String categoryName;

	private String description;

	private static final long serialVersionUID = 1L;

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "MAP_CATEGORY", joinColumns = @JoinColumn(name = "CATEGORYID"), inverseJoinColumns = @JoinColumn(name = "OBJECTID"))
	private List<MapC> mapList = new ArrayList<MapC>();

// Recursion

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "fqQuesCatagory")
	List<ObjectCategory > categoryList = new ArrayList<ObjectCategory>();

	@ManyToOne
	@JoinColumn(name = "PARENTCATEGORY")
	private ObjectCategory fqQuesCatagory

// Recursion
	public FqQuesCatagory() {
		super();
	}

	public String getCategoryname() {
		return this.categoryname;
	}

	public void setCategoryname(String categoryname) {
		this.categoryname = categoryname;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<MapC> getMapList() {
		return faqList;
	}

	public void setFaqList(List<MapC> faqList) {
		this.mapList = mapList ;
	}

	public String getCategoryid() {
		return categoryId;
	}

	public void setCategoryid(String categoryid) {
		this.categoryid = categoryId;
	}

	public List<ObjectCategory> getFqCategoryList() {
		return categoryList;
	}

	public void setFqCategoryList(List<ObjectCategory> categoryList) {
		this.categoryList = categoryList;
	}

	public ObjectCategory getFqQuesCatagory() {
		return fqQuesCatagory;
	}

	public void setFqQuesCatagory(ObjectCategory fqQuesCatagory) {
		this.fqQuesCatagory = fqQuesCatagory;
	}

}

Doesn't SAP JPA support recursive parent-child relationship (highlighted by "// Recursion"). The same model works in TopLink perfectly.

Former Member
Not what you were looking for? View more on this topic or Ask a question