Hi!
I need some assistance on the following problem. I'll explain the scenario in brief.
I have mapped an Employee-table to Employee java objects and a Project table to Project java objects. Simple enough. In the MySQL database, the two tables are joined using a TimeTable table to describe the amount of hours an employee have worked on a project on a specific date. TimeTable looks like this:
Code:
FIELD TYPE KEY
PRJ_InternalID int(11) PRI
EMP_InternalID int(11) PRI
ActualDate varchar(8) PRI
Hours double
To model this in Java, I would prefer to make a class called RegisteredWork which contain a reference to a Project, a date and the amount of hours worked, and then let each Employee object contain a Collection (Set or whatever) of RegisteredWork objects.
Brief sketch of the classes:
Code:
class Employee
{
int id;
String name, etc;
SortedSet timeTable; //contains RegisteredWork objects
public void setTimeTable( SortedSet timeTable )
{
this.timeTable = timeTable;
}
//more getters/setters
}
class Project
{
int id;
String projectname, etc;
//getters/setters
}
classRegisteredWork
{
Project project;
GregorianCalendar date;
double hours;
}
About the date which is stored in TimeTable as VARCHAR, I have a working usertype for that.
Now, is this possible to map in Hibernate? I'm already familiar with many-to-many relations using SortedSet eliminating the need for a Java object for the join table, but I'm having some trouble solving this one.
I hope I have provided enough info, and any help is appreciated!
Best regards,
Rune