/[projects]/miscJava/HiberTest1/src/dk/thoerup/hibertest1/Example1.java
ViewVC logotype

Annotation of /miscJava/HiberTest1/src/dk/thoerup/hibertest1/Example1.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 620 - (hide annotations) (download)
Mon Mar 1 15:33:45 2010 UTC (14 years, 3 months ago) by torben
File size: 1354 byte(s)
Code sync
1 torben 599 package dk.thoerup.hibertest1;
2    
3     import java.util.List;
4    
5    
6    
7     public class Example1 {
8    
9     /**
10     * @param args
11     */
12    
13     public static void printList(List<Employee> emps) {
14     for (Employee e : emps) {
15     System.out.println(" - " + e.getId() + " : " + e.getName() + " (" + e.getDepartment().getName() + ")" );
16     }
17    
18     }
19    
20     public static void main(String[] args) throws Exception {
21     EmployeeDAO dao = new EmployeeDAO();
22    
23     List<Employee> list = dao.getAll();
24    
25     printList(list);
26    
27     Employee emp = dao.getEmployeeById(3);
28 torben 620 Department dept = emp.getDepartment();
29     System.out.println( "Department " + dept.getName() );
30 torben 599
31 torben 620 dept = DepartmentDAO.getDepartmentById( dept.getId() );
32     for (Employee e2 : dept.getEmplyeees()) {
33     System.out.println( e2.getName() );
34     }
35 torben 599
36 torben 620
37 torben 599 /*
38     emp = dao.getEmployeeById(6);
39     System.out.println("Employee #6 : " + emp.getName());
40    
41     String search = "marC";
42     list = dao.getEmployeesByName(search);
43     System.out.println("Employee named '" + search + "' : ");
44     printList(list);
45    
46     Employee emp2 = dao.getEmployeeById(11);
47     emp2.setName("Hello World");
48     dao.updateEmployee(emp2);
49    
50     emp = dao.getEmployeeById(12);
51     if (emp != null)
52     dao.deleteEmployee(emp);
53     else
54     System.out.println("no emp with id=12");*/
55     }
56    
57     }

  ViewVC Help
Powered by ViewVC 1.1.20