mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 08:58:48 +00:00
trabajando en usuarios
This commit is contained in:
33
src/main/java/com/imprimelibros/erp/users/RoleDaoImpl.java
Normal file
33
src/main/java/com/imprimelibros/erp/users/RoleDaoImpl.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.imprimelibros.erp.users;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class RoleDaoImpl implements RoleDao {
|
||||
|
||||
private EntityManager entityManager;
|
||||
|
||||
public RoleDaoImpl(EntityManager theEntityManager) {
|
||||
entityManager = theEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role findRoleByName(String theRoleName) {
|
||||
|
||||
// retrieve/read from database using name
|
||||
TypedQuery<Role> theQuery = entityManager.createQuery("from Role where name=:roleName", Role.class);
|
||||
theQuery.setParameter("roleName", theRoleName);
|
||||
|
||||
Role theRole = null;
|
||||
|
||||
try {
|
||||
theRole = theQuery.getSingleResult();
|
||||
} catch (Exception e) {
|
||||
theRole = null;
|
||||
}
|
||||
|
||||
return theRole;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user