Hi together,
although I've read the threads in this forum, I can't find the best way to solve my current problem.
We've got a rich client (spring rcp) and are trying to display the complex data structure in a JTree.
So far we've used the eager fetching mode, but as the project's elements increased, the performance degrades more and more.
My idea was to switch to lazy loading of the node's children. Now I've read that it would be the best option to use just one session and let this be open the entire lifecycle. Is this right? As I was told, there this approach is dangerous as well, f.e. the session is not thread-safe.
I really can't believe, that there is no best practice for this problem out there.
In my opinion it would be the best way to load the children of a TreeNode once the user clicks on it.
I will post my mapping as well and hope that there are ideas how to cope this challenge.
Thank in advance.
Code:
@Entity
@Table(name = "Feature")
public class Feature extends BaseModel
{
@Id
@GeneratedValue
private Long featureId;
@Basic
private String title;
@Basic
private Integer relevance;
@ManyToOne
@OnDelete(action=OnDeleteAction.CASCADE)
@JoinColumn(name="parent", insertable=false, updatable=false)
private Feature parent;
@OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
@IndexColumn(name="features_position", base=0)
@JoinColumn(name="parent")
private List<Feature> subfeatures;
//getter and setter
}