Hi
I'm new to Hibrenate and i'm having trouble mapping the following case (using annotations) :
I have a table holding a list of folders - each referencing a parent folder :
User_folders : Folder_id integer, Folder_name varchar2(30), Parent_folder_id integer
Folder & Parent folder are of the same class.
I'm trying to create the following mapping :
In the UserFolder class - have the following :
private UserFolder getParentFolder(); - should return the parent folder of the current folder private List<UserFolder> getChildFolders(); - should return a list of folders that their parent folder is the current folder
Here is the class :
@Entity @Table(name = "user_folders") public class UserFolder extends Serializable {
// Members private Integer userFolderId; private UserFolder parentFolder; private List<UserFolder> folders = new ArrayList<UserFolder>();
// Folder id public void setUserFolderId(Integer userFolderId) { this.userFolderId = userFolderId; }
@Id @Column(name = "user_folder_id") @GeneratedValue(generator = "hibseq") @GenericGenerator(name = "hibseq", strategy = "seqhilo", parameters = { @Parameter(name = "sequence", value = "recipeDrawer.user_folder_id_seq") }) public Integer getUserFolderId() { return userFolderId; }
// List of inner folders public void setFolders(List<UserFolder> folders) { this.folders = folders; } public List<UserFolder> getFolders() { return folders; }
// Parent folder id public void setParentFolder(UserFolder parentFolder) { this.parentFolder = parentFolder; } public UserFolder getParentFolder() { return parentFolder; }
}
i've tried looking for such example - but couldn't find any that worked.
Will appreciate any help - or reference to a working example
Thanks Inbal
|