Coder Social home page Coder Social logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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

from hibernate-generic-dao.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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

from hibernate-generic-dao.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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

from hibernate-generic-dao.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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 [email protected] on 3 May 2012 at 8:47

from hibernate-generic-dao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.