Comments (4)
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.
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.
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.
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)
- Entity not being saved HOT 2
- Implement MetadataUtil for JPA 2 metadata model
- JPAAnnotationMetadata only accepts direct public fields in getProps()
- Add Enumeration support to InternalUtil.convertIfNeeded()
- Version 1.1.3 InExpression can not handle values not null but without any elements
- Nested property fetches dont work (first identified in issue 56) HOT 1
- JPABaseDAO - java.lang.NoSuchMethodError HOT 2
- NoSuchMethodError HOT 2
- Sample Projects do have a wrong dao-hibernate version in their poms
- Sample Project hibernate-maven-web does nut run under jetty (?) HOT 1
- How to compare to fields using ==, <=, >= , > , < operators HOT 3
- Search.removeField(property) not work HOT 1
- UUID HOT 1
- GenericDAO Search failed with boolean Column HOT 2
- Not compatible with the latest hibernate
- Issue with Distinct with hibernate 4.3,5 HOT 1
- OP_LIKE is not working
- left join fetch is not working.
- Issue when Implementing Ehcache
- Hibernate 4 Upgrade HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hibernate-generic-dao.