com.quhaodian.user.data.dao.impl.UserRoleDaoImpl Maven / Gradle / Ivy
package com.quhaodian.user.data.dao.impl;
import com.quhaodian.data.core.CriteriaDaoImpl;
import com.quhaodian.data.core.Finder;
import com.quhaodian.user.data.dao.UserRoleDao;
import com.quhaodian.user.data.entity.UserRole;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/**
* Created by imake on 2017年07月20日17:47:47.
*/
@Repository
public class UserRoleDaoImpl extends CriteriaDaoImpl implements UserRoleDao {
@Override
public UserRole findById(Long id) {
if (id == null) {
return null;
}
return get(id);
}
@Override
public UserRole findByName(String name) {
if (name == null) {
return null;
}
Finder finder = Finder.create();
finder.append("from UserRole u where u.name=:name");
finder.setParam("name", name);
return findOne(finder);
}
@Override
public UserRole save(UserRole bean) {
getSession().save(bean);
return bean;
}
@Override
public UserRole deleteById(Long id) {
UserRole entity = super.get(id);
if (entity != null) {
getSession().delete(entity);
}
return entity;
}
@Override
protected Class getEntityClass() {
return UserRole.class;
}
@Autowired
public void setSuperSessionFactory(SessionFactory sessionFactory) {
super.setSessionFactory(sessionFactory);
}
}