Hello,
So i am stuck, i am creating a gwt web application, i will be using a tree(gwt Tree and TreeItems) structure to show a list of folders(class Folder) and files(class FileLocation), the folder and filelocation class will all implement a Hierarchy interface basing the classes on the composite pattern. but i am using hibernate to store my data , and i am using annotations for the mapping of the data to the database. my trouble is i do not know how to annotate my interface.
have any of you guys used the composite pattern while persisting the data with hibernate
public interface Hierarchy(){
// a few abstract methods that will be implemented by the sub classes
}
@Entity
@Table()
public class Folder implements Serializable, Hierarchy {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "folder_id", updatable = false, nullable = false)
private int id;
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
@JoinTable(name = "FOLDER_FILELOCATION", joinColumns = {
@JoinColumn(name = "folder_id") }, inverseJoinColumns = {
@JoinColumn(name = "file_information_id") })
private List<Hierarchy> children = new ArrayList<Hierarchy>() ;
@Column(name = "folder_name")
private String folderName;
@Column(name = "tree_item")
private TreeItem item;
@Column (name = "parent")
private Hierarchy parent;
@Entity
@Table(name = "FILE_INFORMATION_TABLE")
public class FileInformation implements Serializable, Hierarchy {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "file_information_id", updatable = false, nullable = false)
private int fiId;
@Column (name = "location")
private String location;
@Column(name = "tree_item")
private TreeItem item;
@Column (name = "parent")
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinTable(name="FOLDER_FILELOCATION",
joinColumns = @JoinColumn(name="filelocation_id"),
inverseJoinColumns = @JoinColumn(name="folder_ID"))
private Hierarchy parent;