日期:2014-05-20 浏览次数:20824 次
public class User_Update_Dao_Impl implements User_Update_Dao { public boolean updateUser(User user){ @Autowired SessionFactory sessionfactory ; User existinguser; try{ existinguser=getUserByUsername(user.getUsername()); existinguser.setUsername(user.getUsername()); existinguser.setPassword(user.getPassword()); existinguser.setGroupname(user.getGroupname()); existinguser.setApplicationname(user.getApplicationname()); existinguser.setLastname(user.getLastname()); existinguser.setFirstname(user.getFirstname()); existinguser.setEmail(user.getEmail()); existinguser.setAddress(user.getAddress()); existinguser.setDescription(user.getDescription()); sessionfactory.getCurrentSession().update(existinguser); sessionfactory.getCurrentSession().flush(); sessionfactory.getCurrentSession().clear(); return true; }catch(Exception e){ System.out.println("*****Error in update user in Dao: "+e); } return false; } @Override public List<User> listUsers() { // TODO Auto-generated method stub return null; } @Override public User getUserByUsername(String username) { // TODO Auto-generated method stub return null; } }
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>com.hp.sandbox.aa.model.entity.User</value> <value>model.entity.Privilege</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.connection.pool_size">${hibernate.connection.pool_size}</prop> </props> </property> </bean>