Report 2
Report 2
Report 2
Database Design
As it can be seen in the database diagram above, there are only 4 tables,
i.e.,: notification, users, books and hibernate_sequence. In order to
clarify any possible doubts or possible misunderstandings, the following
observations will be mentioned:
Users and notification tables have a one-to-many relationship,
meaning that an user can have multiple notifications.
Users and books tables have a one-to-many relationship, meaning
that an user can reserve or currently have in possession multiple
books.
The reserved_by_user_id field is meant to specify which user
currently reserve a book, whereas in_possession_of_user_id is
meant to reveal the fact that even though the reservation period has
expired for an user, the book hasn’t been returned to the library by
that user.
Hibernate_sequence table is a table that is generated the moment
the strategy for a @GenereatedValue of a field (usually an id) is
set to GenerationType.AUTO. The way Hibernate interprets AUTO
generation type has changed starting with Hibernate version 5.0.
When using Hibernate v 4.0 and Generation Type as AUTO,
specifically for MySql, Hibernate would choose the IDENTITY
strategy (and thus use the AUTO_INCREMENT feature) for
generating IDs for the table in question. Starting with version 5.0
when Generation Type is selected as AUTO, Hibernate uses
SequenceStyleGenerator regardless of the database. In case of
MySql Hibernate emulates a sequence using a table, because
MySql doesn’t support the standard sequence type natively. Hence,
that’s why if strategy AUTO is used, Hibernate will generate a
table called hibernate_sequence to provide the next number for the
ID sequence. (Such details will also be found in the code)
Spring MVC Architecture
The following important package is the one in which all database entity
classes are stored:
The following screenshots show the class for Book Entity:
The following screenshots show the class for Notification Entity
And finally, the following screenshots illustrate the User Entity class:
In this particular screenshot, it is revealed the
package that contains the service layer of
each entity the DAO package. This additional
layer acts a communicator between controller and repository layer and
contains business logic.
The following screenshots will reveal details about how each service
class of each entity was developed thus far. Keep in mind that even
though it may seem complete, I believe that some methods might need
some improvements, others need to be removed and maybe replaced
with completely methods, some need some code refactoring for better
code reading, etc.
Here are some examples of the current user interfaces, because not all of
them are 100% and still need some improvements:
Last Remark: The only thing that wasn’t fully respected in this
architecture was the fact that I didn’t manage to update the admin role to
have the feature to manage books instead of the employee.