-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewAllInventory.java
More file actions
49 lines (35 loc) · 1.25 KB
/
ViewAllInventory.java
File metadata and controls
49 lines (35 loc) · 1.25 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
39
40
41
42
43
44
45
46
47
48
49
package entities;
import java.util.List;
import org.example.beans.Inventory;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
@SuppressWarnings("deprecation")
public class ViewAllInventory
{
public static void viewAllInventoryDetails()
{
Configuration cfg = new Configuration();
cfg.configure("resources/hibernate.cfg.xml");
SessionFactory sf = cfg.buildSessionFactory();
/*
* Configuration and SessionFactory is responsible for create the table
*/
Session s = sf.openSession();
Criteria criteria = s.createCriteria(Inventory.class);
@SuppressWarnings("unchecked")
List<Inventory> list=criteria.list();
//Criteria fixed for showing all the product list using loop
for(Inventory stu:list)
{
System.out.println("===============================================================");
System.out.println(stu.getId()+" | "+stu.getName()+" | "+stu.getType()+" | "+stu.getQuantity()+" | "+stu.getPrice());
}
System.out.println("===============================================================");
/**
* Transaction Code commit
*/
s.beginTransaction().commit();
}
}