I’m using this tutorial: http://www.objectdb.com/tutorial/jpa/eclipse/ee/ejb
Is the persist function required? The class isn’t extending any other classes.
Is DAO required in my model name? I see List<Guest> is <Guest> referring to GuestDao or the package name? If I had to guess I’d say GuestDao
Thanks for clearing this up
The
persistmethod is a type-safepersistmethod. It can cut down one type of programming error (saving the wrong entity type through the DAO).It’s required in the sense that a
GuestDaowould be expected to haveGuest-specific methods.It also keeps knowledge of the persistence mechanism itself out of the mainline code: separation of concerns. All the mainline code needs to do is persist guests via the DAO.
Daois not required in the model name. It would actually be confusing, since it wouldn’t be a DAO.Guestrefers to a guest.GuestDaorefers to a DAO forGuests.List<Guest>refers to a collection of guests.Listis a generic type, the symbol between the"<>"is the collection type, in this case,Guest.Guestrefers to exactly that–theGuestclass.