Help regarding composite pattern with hibernate

Posted by molleman on Stack Overflow See other posts from Stack Overflow or by molleman
Published on 2010-04-08T21:58:33Z Indexed on 2010/04/08 22:03 UTC
Read the original article Hit count: 340

Filed under:
|
|
|
|

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 extends Hierarchy implements Serializable {
@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 extends Hierarchy implements Serializable {

@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")
private Hierarchy parent;

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about java