-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathStackDAO.java
30 lines (24 loc) · 933 Bytes
/
StackDAO.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.booking.dao;
import org.hibernate.Query;
import org.hibernate.Session;
import com.booking.modelo.HibernateUtil;
import com.booking.persistencia.Stack;
/************************************************
* Define las operaciones sobre stacks en la base de datos
* @author Ismael Núñez
*
************************************************/
public class StackDAO extends GenericEntity<Stack> {
public StackDAO() {
super(Stack.class);
}
/************************************************
* Obtiene la cantidad total de libros prestados.
* @return Cantidad de libros prestados.
************************************************/
public int totalLibrosPrestados() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Query query = session.createQuery("SELECT SUM(s.cantidad) FROM Stack s");
return ((Number) query.uniqueResult()).intValue();
}
}