This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Recursive table with non-primary key field problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Recursive table with non-primary key field problem" Watch "Recursive table with non-primary key field problem" New topic
Author

Recursive table with non-primary key field problem

Pablo Mino
Greenhorn

Joined: Aug 11, 2009
Posts: 28
Hi, I got a problem I really don't know how to tackle

Got 1 table:

FOLDER
----------
AutonumericID NUMBER(20,0) PK
User VARCHAR(100) FK
FolderID VARCHAR(250)
ParentFolderID VARCHAR(250)

Turns out that if 2 users have a folder with the same name, the FolderID is identical, for which the autonumericID is used. I know there should be a PK with USER & FolderID then but we can't make that change.

I'm using Hibernate, I'm able to do something like UserDAO.getFolders() and I would like to be able to ask that collection for a Collection of child folders, this was my attempt:



This doesn't work because its actually trying to map the parentFolderID to the autonumericID.

My goal is to prevent having to create another DAO for the folder class and having to map the childs manually.

Any idea is welcome, thanks in advance
 
Don't get me started about those stupid light bulbs.
 
subject: Recursive table with non-primary key field problem
 
Similar Threads
Populate child table foreign keys from primary table?
OneToOne relation gives problem
problem with one-to-one mapping
Removing from collection in many-to-one bi-directional mapping not working
identifier of an instance of <class> was altered from old to null