Homework 3
CS520, Spring 2009
Due: Friday, April 24
Package all the source files of your project into a zip file using the zip Ant target you
developed in Homework 1, and
upload the zip file to CSNS.
Note that file
uploading will be disabled automatically after 11:59PM
of the due date, so please turn in your work on time.
[Reading]
- Hibernate Book (Java
Persistence with Hibernate)
- Chapter 1-6 (or corresponding chapters in Hibernate in Action).
You may skip anything related to XDoclet,
Annotation, JPA, and EJB.
- Hibernate
Documentation
- CSNS Source Code
- Model classes under src/csns/model
- Hibernate mapping files under src/hbm
[Blogs for CSNS]
Blogs is a new component of CSNS which you will develop in this quarter. In
this assignment you are going to implement the model classes
and the database schema based
on the following requirements:
- Each CSNS user may create a blog of their own.
- A blog has a title, a description, a banner image (which could be hosted either on CSNS or somewhere else), and a number of blog entries.
- A blog entry has a
title, content, and a timestamp indicating the time at which the entry
was posted. A blog entry may also have file attachments.
- Only the owner of a blog can add entries to the blog.
- Any CSNS users can add comments to any blog entry, whether they own the blog or not.
- A comment does not have a title, but does have content and a timestamp, and may have file attachments, too.
[Model] (20pt)
Design and implement the model classes for the blogs component, i.e. Blog, BlogEntry, and Comment. You may also need to change some existing classes. The classes should be placed under the package csns.model.blog. Note that in this assignment you only
need to create the model classes. Operations such as creating blogs and
adding entries/comments will be implemented later in subsequent
assignments.
[Hibernate Mapping] (30pt)
Create Hibernate mapping files for the classes you created in the previous exercise, and place these mapping files under src/hbm/blog.
If you have changed any existing classes in the previous exercise, you
need to modify their Hibernate mapping files accordingly.
Run the hbm2ddl Ant task to generate a new db/csns.ddl file and check if the database schema is what you expect.
[Database Scripts] (20pt)
Based on the csns.ddl file generated in the previous exercise, modify the following database scripts:
- db/csns-create.sql - add the SQL statements to create the tables/constraints for the blogs
- db/csns-drop.sql - add the SQL statements to drop the tables/constraints for the blogs
- db/csns-test-insert.sql - add the SQL statements to create two test cases:
- A blog for user i0001. The blog should have three entries, one posted in 1/2009, and the other two in 3/2009.
- A blog for user s0001. The blog should have three entries, two posted in 2/2009, and the other one in 3/2009.
Details of the test cases, i.e. blog title, content of the entries, and so on, are up to you.
[Subversion]
Commit all the changes to your Subversion repository, and
create a tag called cs520-hw3.