-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduledEmployeeAlert.java
More file actions
38 lines (32 loc) · 1.01 KB
/
ScheduledEmployeeAlert.java
File metadata and controls
38 lines (32 loc) · 1.01 KB
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
31
32
33
34
35
36
37
38
package org.javaee7.chapter11;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.javaee7.entity.Employee;
/**
* Chapter 11 - Scheduled Logger
* @author Juneau
*/
public class ScheduledEmployeeAlert implements Runnable {
EntityManagerFactory emf = null;
EntityManager em = null;
@Override
public void run() {
emf = Persistence.createEntityManagerFactory("IntroToJavaEE7PU");
em = emf.createEntityManager();
queryEmployees();
}
public void queryEmployees(){
EntityTransaction entr = em.getTransaction();
entr.begin();
String qry = "select object(o) from Employee o";
Query query = em.createQuery(qry);
List<Employee> emps = query.getResultList();
for(Employee emp: emps){
// if employee is new then alert
}
}
}