org.appfuse.dao.jpa
Class UserDaoJpa

java.lang.Object
  extended by org.appfuse.dao.jpa.GenericDaoJpa<User,java.lang.Long>
      extended by org.appfuse.dao.jpa.UserDaoJpa
All Implemented Interfaces:
GenericDao<User,java.lang.Long>, UserDao, org.springframework.security.userdetails.UserDetailsService

@Repository(value="userDao")
public class UserDaoJpa
extends GenericDaoJpa<User,java.lang.Long>
implements UserDao, org.springframework.security.userdetails.UserDetailsService

This class interacts with Spring's HibernateTemplate to save/delete and retrieve User objects.

Author:
Matt Raible Modified by Dan Kibler Extended to implement Acegi UserDetailsService interface by David Carter david@carter.net Modified by Bryan Noll to work with the new BaseDaoHibernate implementation that uses generics.

Field Summary
 
Fields inherited from class org.appfuse.dao.jpa.GenericDaoJpa
log, PERSISTENCE_UNIT_NAME
 
Constructor Summary
UserDaoJpa()
          Constructor that sets the entity to User.class.
 
Method Summary
 java.lang.String getUserPassword(java.lang.String username)
          Retrieves the password in DB for a user
 java.util.List<User> getUsers()
          Gets a list of users ordered by the uppercase version of their username.
 org.springframework.security.userdetails.UserDetails loadUserByUsername(java.lang.String username)
          Gets users information based on login name.
 User saveUser(User user)
          Save user and flush entityManager
 
Methods inherited from class org.appfuse.dao.jpa.GenericDaoJpa
exists, get, getAll, getAllDistinct, getEntityManager, remove, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.appfuse.dao.GenericDao
exists, get, getAll, getAllDistinct, remove, save
 

Constructor Detail

UserDaoJpa

public UserDaoJpa()
Constructor that sets the entity to User.class.

Method Detail

getUsers

public java.util.List<User> getUsers()
Gets a list of users ordered by the uppercase version of their username.

Specified by:
getUsers in interface UserDao
Returns:
List populated list of users

loadUserByUsername

@Transactional
public org.springframework.security.userdetails.UserDetails loadUserByUsername(java.lang.String username)
                                                                        throws org.springframework.security.userdetails.UsernameNotFoundException
Gets users information based on login name.

Specified by:
loadUserByUsername in interface UserDao
Specified by:
loadUserByUsername in interface org.springframework.security.userdetails.UserDetailsService
Parameters:
username - the user's username
Returns:
userDetails populated userDetails object
Throws:
org.springframework.security.userdetails.UsernameNotFoundException - thrown when user not found in database

saveUser

public User saveUser(User user)
Save user and flush entityManager

Specified by:
saveUser in interface UserDao
Parameters:
user - the user to save
Returns:
the updated user

getUserPassword

public java.lang.String getUserPassword(java.lang.String username)
Retrieves the password in DB for a user

Specified by:
getUserPassword in interface UserDao
Parameters:
username - the user's username
Returns:
the password in DB, if the user is already persisted


Copyright © 2003-2009. All Rights Reserved.