-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: inheritance and design in calendar application
PostPosted: Thu Jan 03, 2008 6:16 am 
Newbie

Joined: Wed Jan 02, 2008 11:01 am
Posts: 1
Hi All,

Technical Info:
DB- Mysqul 5.0
Hibernate version 3.2

I having some design difficulties in my calendar application.
The tricky part is the setting up the “meeting” class:

public class Meeting {
private Long meetingId;

private Date startMeetingDate;
private Date endMeetingDate; //if it reccurence it can be null;
private User user;
private Route route;

//use for reccurence 0- Sunday until 6-Saturday
private Integer dayOfWeek;

private Manager mannagerRecurrenceId;
private byte status;

…getter and setter for all above

Now, for every Meeting there will be a “manager” and “participants” who are derived from the Meeting class as follow:
public class Manager extends Meeting{

//default constructor - for reflection
public Manager(){super();}

private int numberOfFreeParticipants;
private Set<Participant> participants = new HashSet <Participant>();

…getter and setter for all above

public class Participant extends Meeting{

//default constrictor - for reflection
public Participant(){super();}

private int numOfDonuts;
private int numOfCoffeeCups;

private int rank;

private Manager manager;
…getter and setter for all above

And now for the mapping:
<hibernate-mapping package="cpo.entity" >

<class name="Meeting" table="MEETINGS">

<id name="meetingId" column="MEETING_ID">
<generator class="native"/>
</id>
<property name="dayOfWeek"/>
<many-to-one name="managerRecurrenceId" class="Manager" column="managerRecurrenceId" />

<many-to-one name="route" class="Route"/>
<property name="status"/>
<property name="startMeetingDate" type="timestamp" column="START_MEETING_DATE"/>
<property name="endMeetingDate" type="timestamp" column="END_MEETING_DATE"/>

<joined-subclass name="Manager" table="MANAGERS">
<key column="MEETING_ID"/>
<property name=" numberOfFreeParticipants "/>
<set name="participants" inverse="true" cascade="all-delete-orphan" table="MANAGER_PARTICIPANTS" >
<key column="FK_MANAGER_MEETING_ID"/>
<one-to-many class="Participant"/>
</set>
<many-to-one name="user" class="User" column="user_id" />
</joined-subclass>

<joined-subclass name="Participant" table="PESSANGERS">
<key column="MEETING_ID"/>
<property name=" numOfDonuts"/>
<property name=" numOfCoffeeCups "/>
<property name="rank"/>
<many-to-one name="manager" lazy="false" class="Manager" cascade="none" />
<many-to-one name="user" class="User" column="user_id" />
</joined-subclass>

</class>
</hibernate-mapping>

Finally I have the User:
public class User implements Cloneable{

private Long userID;
private String userLogIn;
private String password;
private String firstName;
private String lastName;
private String nickName;
private String phone;
private String emailAddress;
private boolean notificationBySms;
private boolean notificaitonByEmail;
private Company company;
private Set <Participant> participants= new HashSet <Participant>();
private Set <Manager> managers = new HashSet <Manager>();

user mapping:
<hibernate-mapping package="cpo.entity">
<class name="User" table="USERS" lazy="false" >
<id name="userID" column="USER_ID">
<generator class="native"/>
</id>
<property name="firstName"/>
<property name="lastName"/>
<property name="password"/>
<property name="userLogIn"/>
<property name="nickName"/>
<property name="phone"/>
<property name="emailAddress"/>
<property name="notificationBySms"/>
<property name="notificaitonByEmail"/>
<set name="participants" table="USERS_PARTICIPANTS" cascade="all" lazy="false">
<key column="USER_ID"/>
<one-to-many class="Participant"/>
</set>
<set name="managers" table="USERS_MANAGERS" cascade="all" lazy="false">
<key column="USER_ID"/>
<one-to-many class="Manager"/>
</set>
<one-to-one name="company" class="Company" cascade="all"/>
</class>
</hibernate-mapping>

Each user holds his “meetings” both as Manager and Participant
The problem is for deleting all the participants when acting as a manager it seems that my links are not in order.

I will be more then happy to hear any insights and suggestions.

Amir


Top
 Profile  
 
 Post subject: Re: inheritance and design in calendar application
PostPosted: Fri Jan 04, 2008 11:17 am 
Newbie

Joined: Fri Dec 21, 2007 3:52 pm
Posts: 2
Hi Amir,
I can't see why Manager and Participant should subclass Meeting. If the manager needs details of the meeting being managed, it should hold a reference to the Meeting object. Similarly for Participants. You would then have bidirectional 1-1 association between Manager and Meeting and a bideiretional 1-many association between Meeting and Participants.

HTH

Regards, Steve


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.