trabajando en usuarios

This commit is contained in:
2025-09-26 15:13:11 +02:00
parent 062a20c26a
commit 01a1ac4b71
30 changed files with 937 additions and 139 deletions

View 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;
}
}