Getting Non-Root Parent in self referencing relationship

Hi All,

I’m using the JPAContainer and HierarchicalContainer to get create a TreeTable for a self-referencing relation ship. My entity is as below

public class EPurse implements Serializable {    

    private static final long serialVersionUID = 1565360351477665200L;
    
    @Column(name="EP_ID")
    private int id;
    
    @Column(name="EP_Name")
    private String accountName;
    
    @Id
    @Column(name="EP_ANI")
    private String msisdn;
    
    @Column(name="EP_AuthPass")
    private String authPass;
    
    @Column(name="EP_UplineANINo")
    private String accountNumber;
    
    @ManyToOne
    @JoinColumn(name = "EP_UplineANINo" , insertable=false, updatable=false)
    private EPurse parent;
    
    @OneToMany(mappedBy="parent")
    private List<EPurse> children;
    
    public void setParent(EPurse parent) {
        this.parent = parent;
    }
    public List<EPurse> getChildren() {
        return children;
    }
    public void setChildren(List<EPurse> children) {
        this.children = children;
    }

}

And I use this code to populate the TreeTable

[code]
CachingMutableLocalEntityProvider entityProvider = new CachingMutableLocalEntityProvider(EPurse.class,em);
final JPAContainer ePurse = new JPAContainer(EPurse.class) {
private static final long serialVersionUID = 1827106776364469552L;
@Override
public boolean areChildrenAllowed(Object itemId) {
return getChildren(itemId).size() > 0;
}
};
ePurse.setEntityProvider(entityProvider);
ePurse.setParentProperty(“parent”);

    final TreeTable businessUnitTree = new TreeTable("Business Units", ePurse);

[/code]which works perfectly for the Root Element (Where Parent Id (EP_UplineANINo) is null). However If i want to Filter the JPA container by giving the msisdn in the filter it will not retrieve anything since internally it searches for EP_UplineANINo IS NULL and MSISDN = .

My question is how can I get an entity and its children when its not the root element of a tree.

Ive been stumped by this issue for a while .Any help is appreciated. Thanks in advance.

Regards
Bill