martbl wrote:
Also,
as long as I have an object in the persistance store, I can use the DAO to get it.. but what's the best way to persist a newly created object?
I mean I could Item item = itemDAO.getItem(id); if I have an item in the db..
but if I do
Item item = new Item();
// set item's properties
then using the architecture describe in the book, in the filter, the session would be close and therefor all persistance object would be saved. but since my newly created item is in transient state, it needs to be attached in some ways to the session. How should it be done according to the Hibernate in action book?
Thanks again.
Hi martbl,
you could write a abstract BaseDAO class with owns a generic save(Object objectToSave) method. In this case just inherit each DAO from your base dao an associate your transient objects by calling the save method.
simon