Mark -
This is my first attempt at managing a foreign-key relationship with hibernate so please bear with me.
Instances of my User class are maintained in an LDAP directory, task instances are stored in my relational DB. A quick look at my class definitions are as follows (instance values displayed in parens):
class User
-
String dn (cn=john doe,o=myorganization)
- String firstName (john)
- String lastName (doe)
class Task
- int id (43)
- String name (mytask)
- User owner (*objectref*)
I would like to store the "dn" of the user instance in a task record. The resulting DB record is below:
mydb.dbo.tasks
- id (43)
- name (mytask)
- owner (cn=john doe,o=myorganization)
I have considered two approaches to resolving this issue, but they are based on my limited experience with hibernate. Perhaps you can make a recommendation:
1.) Store User instances in a DB table and define a one-to-one relationship.
2.) Store only the "dn" in the Task record and use a DAO to create the user instance from an LDAP directory.
My second approach seems best, however, I'm not sure of the appropriate way to handle the mapping. I assumed a dot-notation in the mappings file to write the "dn" to the task record (please see my initial post). Can you provide a recommendation?
Thanks!
R. Alcazar