Open GoogleCodeExporter opened 9 years ago
I think the cause of your null pointer exception is that you need to set the
SessionFactory on the DAO.
You do bring up a good question why we have our own version of save or update.
It is
to that we can return the boolean value of whether it was a new or existing
entity.
However, I don't know if anyone really would use that information anyway. I
would
love to hear what the user community has to say about it. If no one finds it
helpful,
we might as well get rid of it. But in any case, you should still specify a
SessionFactory on the DAO to make everything work properly.
Thanks for the bug report.
Original comment by dwolvert
on 25 Aug 2009 at 5:08
The overriding the getSession() method is not a right method to set the
sessionfactory in GeneralDAOImpl?
can you provide me a short example of the best pratice to set it?
anyway I think that the boolean return value yuo're talking about is a very
useful
thing (I always was asking myself why do Hibernate don't implemented this...)
Compliments for the great work!
best regards,
Stefano.
Original comment by rastrano
on 4 Dec 2009 at 12:30
I afound the answer to latter question in your documentation:
Each DAO and the SearchFacade needs both a Session and a SessionFactory in
order to
work. By default they expose a public setSessionFactory() method and use
SessionFactory.getCurrentSession() to get a Session whenever they need it. With
this
configuration the SessionFactory is required and is generally set once when the
object is initialized.
thank you.
Stefano.
Original comment by rastrano
on 4 Dec 2009 at 12:36
org.hibernate.QueryException: undefined alias: id
from this code
dao.save(entity);
and solved by this
dao._saveOrUpdate(entity);
So why don't we modify the following two methods to use saveOrUpdate()?
public boolean save(Object entity) {
return _saveOrUpdateIsNew(entity);
}
public boolean[] save(Object... entities) {
return _saveOrUpdateIsNew(entities);
}
Modify to
public boolean save(Object entity) {
return _saveOrUpdate(entity);
}
public boolean[] save(Object... entities) {
return _saveOrUpdate(entities);
}
Original comment by ngpeij...@gmail.com
on 3 May 2012 at 8:47
Original issue reported on code.google.com by
rastrano
on 25 Aug 2009 at 12:09