ORM model and DAO in my particular case

Posted by EugeneP on Stack Overflow See other posts from Stack Overflow or by EugeneP
Published on 2010-03-16T10:53:11Z Indexed on 2010/03/16 10:56 UTC
Read the original article Hit count: 458

Filed under:
|
|

I have the DB structure as follows:

table STUDENT (say, id, surname, etc)

table STUDENT_PROPERTIES (say, name_of_the_property:char, value_of_the_property:char, student_id:FK)

table COURSE (id, name, statusofcourse_id)

table STATUSOFCOURSE (id, name_of_status:char ('active','inactive','suspended' etc))

table STUDENT_COURSE (student_id,course_id,statusofcourse_id)

Let's try to pick up domain objects in my database:

Student and Course are main entities. Student has a list of courses he attends, also he has a list of properties, that is all for this student.

Next, Course entitity. It may contain a list of students that attend it.

But in fact, the whole structure looks like this: the starting point is Student, with it's PK we can look a list of his properties, then we look into the STUDENT_COURSE and extract both FK of the Course entity and also the Status of the combination, it would look like "Student named bla bla, with all his properties, attends math and the status of it is "ACTIVE".

now, quotation

1) Each DAO instance is responsible for one primary domain object or entity. If a domain object has an independent lifecycle, it should have its own DAO.

2) The DAO is responsible for creations, reads (by primary key), updates, and deletions -- that is, CRUD -- on the domain object.

Now, first question is What are entities in my case? Student, Course, Student_Course, Status = all except for StudentProperties? Do I have to create a separate DAO for every object?

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate