wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes How to map? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to map?" Watch "How to map?" New topic
Author

How to map?

Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
I have a problem about OR mapping.

The situation is:
Branches have departments, and each department of branch could
have groups. And sometimes, groups could directly belong to branch but not
department.

Suppose I have the following classes,

Class Branch
-------------
int branchID
String name
Department[] dept
Group[] group

Class Department
----------------
int deptID
String deptName

Class Group
----------------
int groupID
String groupName

How to set dept and group in branch table?
Are these three classes could satisfy the situation?

Thanks for advise.
karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
what ORM tool are you using ?
k
Loren Rosen
Ranch Hand

Joined: Feb 12, 2003
Posts: 156
What's the real significance of the department/branch/group distinction? Do you need to store very different data for each? Are their lots of business rules regarding their behavior?
Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
I don't use any ORM tool.
I just want to know how to map the classes to the relational tables.
Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
I think the distinction of the department/branch/group is not very obvious.
Because they all have names, id ...etc.
But their relationship is like a tree. For instance,
branch has some departments, and departments have groups,
and sometimes branch has groups.

And their bahaviors are not all the same, just like different employees in different departments don't have the same behaviors.
Loren Rosen
Ranch Hand

Joined: Feb 12, 2003
Posts: 156
Here's the reason I ask: One approach is to just use a single class (and corresponding table), called, say, OrganizationalUnit. There could also be an OUType class, essentially an enumeration. Then label the OUs with their types, and enforce the requirements about fits where in the tree as business rules. One reason for doing it this way is that the rules may change over time.
Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
Thank you. I will try the method you said.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to map?
 
Similar Threads
LazyInitializationException
LazyInitializationException
Marshalling XML with Spring (How to handle referenced classes)
LazyInitializationException
how can we call valueobject class in servlet