-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteInventory.java
More file actions
32 lines (27 loc) · 847 Bytes
/
DeleteInventory.java
File metadata and controls
32 lines (27 loc) · 847 Bytes
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
package entities;
import java.util.Scanner;
import org.example.beans.Inventory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class DeleteInventory
{
public static void deleteInventoryDetails()
{
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();
Inventory st = new Inventory();
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
System.out.println("Enter The Product Id For Delete Product Inventory ");
int id= sc.nextInt();
st.setId(id);
s.delete(st);
s.beginTransaction().commit();
}
}