Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenericDao don't insert #4

Open
GoogleCodeExporter opened this issue Feb 26, 2016 · 7 comments
Open

GenericDao don't insert #4

GoogleCodeExporter opened this issue Feb 26, 2016 · 7 comments

Comments

@GoogleCodeExporter
Copy link

I have:

My DAO Interface:

{{{
public interface UserDao extends IDao<User, Long> {

    void persist(User user);

    User findByLogin(String login);

}
}}}


My DAO Implementation:

{{{
@Repository
@Transactional(readOnly = true)
public class UserDaoImpl extends GenericDao<User, Long> implements UserDao {

    public UserDaoImpl() {
    }

    @SuppressWarnings("unchecked")
    public User findByLogin(String login) {
        List<User> list = findByCriteria(Criteria.forClass(User.class).add(
                Restrictions.eq("login", login)));

        if (list == null || list.size() != 1) {
            return null;
        }

        return list.get(0);

    }
}

}}}

But when i need save in the controller with: userDao.save(user) nothings
happen in the database.


I have using Spring + Spirng MVC + JPA + Hibernate

I need help, thanks you.


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 11 Sep 2009 at 5:10

@GoogleCodeExporter
Copy link
Author

I think that your problem is that UserDaoImpl must be a EJB. I don't know if 
Spring
can work with PersistenceContext.
In my case, i work with JBoss Application Server, and same code as you write 
works fine.

Original comment by [email protected] on 11 Sep 2009 at 5:55

@GoogleCodeExporter
Copy link
Author

I'm using tomcat, can this to be the problem?

Original comment by [email protected] on 11 Sep 2009 at 6:11

@GoogleCodeExporter
Copy link
Author

where is you void persist(User user) implementation ?

Original comment by [email protected] on 11 Sep 2009 at 8:07

@GoogleCodeExporter
Copy link
Author

to in no place, because he thought he could use the Save method of the parent 
class:

userDao.save(user);

Original comment by [email protected] on 11 Sep 2009 at 8:09

@GoogleCodeExporter
Copy link
Author

Really, i don't know.

I think that Spring should properly inject the persistence unit, regardless of 
the
container. But, as I use the JBoss application server simply can not tell you 
the
result of using Tomcat. 

I honestly do not know if I can help you much, since you are using a different
environment which I have running.

Original comment by [email protected] on 11 Sep 2009 at 11:49

@GoogleCodeExporter
Copy link
Author

The fact is that you must continue to find out about the injection of the 
persistence
unit, poorly engineered design may be affecting the dependency injection.

Original comment by [email protected] on 11 Sep 2009 at 11:50

@GoogleCodeExporter
Copy link
Author

ok thanks, I will continue looking and I can say

Original comment by [email protected] on 12 Sep 2009 at 1:27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant