├── HibProj-Le03
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── telusko
│ └── Main.java
├── HibProj-Le04
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── telusko
│ ├── Main.java
│ └── Student.java
├── HibProj-Le05
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le06
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le07
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le08
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le09
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le10
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le11
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le13
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le14
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le15
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le16
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le19
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le20
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
├── HibProj-Le21
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── material_theme_project_new.xml
│ ├── misc.xml
│ └── vcs.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── telusko
│ │ ├── Alien.java
│ │ ├── Laptop.java
│ │ ├── Main.java
│ │ └── Student.java
│ └── resources
│ └── hibernate.cfg.xml
└── HibProj-Le22
├── .gitignore
├── .idea
├── .gitignore
├── encodings.xml
├── material_theme_project_new.xml
├── misc.xml
└── vcs.xml
├── pom.xml
└── src
└── main
├── java
└── com
│ └── telusko
│ ├── Alien.java
│ ├── Laptop.java
│ ├── Main.java
│ └── Student.java
└── resources
└── hibernate.cfg.xml
/HibProj-Le03/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le03/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le03/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le03/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le03/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le03/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/HibProj-Le03/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 | org.postgresql
20 | postgresql
21 | 42.7.3
22 |
23 |
24 |
25 | org.hibernate.orm
26 | hibernate-core
27 | 6.6.3.Final
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le03/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | public class Main {
4 | public static void main(String[] args) {
5 | System.out.println("Hello, World!");
6 | }
7 | }
--------------------------------------------------------------------------------
/HibProj-Le04/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le04/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le04/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le04/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le04/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le04/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/HibProj-Le04/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le04/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.cfg.Configuration;
6 |
7 | public class Main {
8 | public static void main(String[] args) {
9 |
10 | Student s1 = new Student();
11 | s1.setRollNo(101);
12 | s1.setsName("Navin");
13 | s1.setsAge(30);
14 | Configuration cfg=new Configuration();
15 | SessionFactory sf=cfg.buildSessionFactory();
16 | Session session = sf.openSession();
17 | session.save(s1);
18 |
19 | System.out.println(s1);
20 |
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/HibProj-Le04/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | public class Student {
4 |
5 | private int rollNo;
6 | private String sName;
7 | private int sAge;
8 |
9 | public int getsAge() {
10 | return sAge;
11 | }
12 |
13 | public void setsAge(int sAge) {
14 | this.sAge = sAge;
15 | }
16 |
17 | public String getsName() {
18 | return sName;
19 | }
20 |
21 | public void setsName(String sName) {
22 | this.sName = sName;
23 | }
24 |
25 | public int getRollNo() {
26 | return rollNo;
27 | }
28 |
29 | public void setRollNo(int rollNo) {
30 | this.rollNo = rollNo;
31 | }
32 |
33 |
34 | @Override
35 | public String toString() {
36 | return "Student{" +
37 | "rollNo=" + rollNo +
38 | ", sName='" + sName + '\'' +
39 | ", sAge=" + sAge +
40 | '}';
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/HibProj-Le05/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le05/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le05/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le05/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le05/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le05/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le05/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le05/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | public class Main {
9 | public static void main(String[] args) {
10 |
11 | Student s1 = new Student();
12 | s1.setRollNo(101);
13 | s1.setsName("Navin");
14 | s1.setsAge(30);
15 | Configuration cfg = new Configuration();
16 | cfg.addAnnotatedClass(com.telusko.Student.class);
17 | cfg.configure("hibernate.cfg.xml");
18 | SessionFactory sf = cfg.buildSessionFactory();
19 | Session session = sf.openSession();
20 | Transaction transaction = session.beginTransaction();
21 |
22 | session.save(s1);
23 |
24 | transaction.commit();
25 | System.out.println(s1);
26 |
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/HibProj-Le05/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le05/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 |
9 | update
10 |
11 |
--------------------------------------------------------------------------------
/HibProj-Le06/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le06/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le06/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le06/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le06/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le06/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le06/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le06/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | public class Main {
9 | public static void main(String[] args) {
10 |
11 | Student s1 = new Student();
12 | // s1.setRollNo(102);
13 | // s1.setsName("Kiran");
14 | // s1.setsAge(25);
15 |
16 |
17 | // s1.setRollNo(104);
18 | // s1.setsName("Sushil");
19 | // s1.setsAge(19);
20 |
21 | s1.setRollNo(105);
22 | s1.setsName("Gaurav");
23 | s1.setsAge(22);
24 |
25 | Configuration cfg = new Configuration();
26 | cfg.addAnnotatedClass(com.telusko.Student.class);
27 | cfg.configure("hibernate.cfg.xml");
28 | SessionFactory sf = cfg.buildSessionFactory();
29 | Session session = sf.openSession();
30 | Transaction transaction = session.beginTransaction();
31 |
32 | session.persist(s1);
33 |
34 | transaction.commit();
35 | System.out.println(s1);
36 |
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/HibProj-Le06/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le06/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | update
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le07/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le07/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le07/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le07/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le07/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le07/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le07/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le07/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | public class Main {
9 | public static void main(String[] args) {
10 |
11 | Student s1 = new Student();
12 |
13 |
14 | s1.setRollNo(106);
15 | s1.setsName("Avni");
16 | s1.setsAge(21);
17 |
18 |
19 | SessionFactory sf = new Configuration()
20 | .configure()
21 | .addAnnotatedClass(com.telusko.Student.class)
22 | .buildSessionFactory();
23 |
24 | Session session = sf.openSession();
25 | Transaction transaction = session.beginTransaction();
26 |
27 | session.persist(s1);
28 |
29 |
30 | transaction.commit();
31 | session.close();
32 | sf.close();
33 | System.out.println(s1);
34 |
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/HibProj-Le07/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le07/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | update
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le08/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le08/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le08/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le08/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le08/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le08/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le08/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le08/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.cfg.Configuration;
6 |
7 | public class Main {
8 | public static void main(String[] args) {
9 |
10 | Student s1 = new Student();
11 |
12 |
13 | s1.setRollNo(106);
14 | s1.setsName("Avni");
15 | s1.setsAge(21);
16 |
17 | Student s2 = null;
18 |
19 | SessionFactory sf = new Configuration()
20 | .configure()
21 | .addAnnotatedClass(com.telusko.Student.class)
22 | .buildSessionFactory();
23 |
24 | Session session = sf.openSession();
25 | s2 = session.get(Student.class, 102);
26 |
27 | session.close();
28 | sf.close();
29 | System.out.println(s2);
30 |
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/HibProj-Le08/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le08/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | update
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le09/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le09/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le09/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le09/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le09/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le09/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le09/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le09/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | public class Main {
9 | public static void main(String[] args) {
10 |
11 | Student s1 = new Student();
12 |
13 |
14 | // s1.setRollNo(103);
15 | // s1.setsName("Harsh");
16 | // s1.setsAge(23);
17 |
18 | // s1.setRollNo(109);
19 | // s1.setsName("Anvit");
20 | // s1.setsAge(29);
21 |
22 | SessionFactory sf = new Configuration()
23 | .configure()
24 | .addAnnotatedClass(com.telusko.Student.class)
25 | .buildSessionFactory();
26 |
27 | Session session = sf.openSession();
28 | s1 = session.get(Student.class, 109);
29 | Transaction transaction = session.beginTransaction();
30 | session.remove(s1);
31 | transaction.commit();
32 | session.close();
33 | sf.close();
34 | System.out.println(s1);
35 |
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/HibProj-Le09/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le09/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | update
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le10/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le10/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le10/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le10/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le10/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le10/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le10/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le10/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.*;
4 |
5 | @Entity
6 | @Table(name = "alien_table")
7 | public class Alien {
8 |
9 | @Id
10 | private int aid;
11 |
12 | @Column(name = "alien_name")
13 | private String aname;
14 |
15 | @Transient
16 | private String tech;
17 |
18 | public int getAid() {
19 | return aid;
20 | }
21 |
22 | public void setAid(int aid) {
23 | this.aid = aid;
24 | }
25 |
26 | public String getTech() {
27 | return tech;
28 | }
29 |
30 | public void setTech(String tech) {
31 | this.tech = tech;
32 | }
33 |
34 | public String getAname() {
35 | return aname;
36 | }
37 |
38 | public void setAname(String aname) {
39 | this.aname = aname;
40 | }
41 |
42 |
43 | @Override
44 | public String toString() {
45 | return "Alien{" +
46 | "aid=" + aid +
47 | ", aname='" + aname + '\'' +
48 | ", tech='" + tech + '\'' +
49 | '}';
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/HibProj-Le10/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | public class Main {
9 | public static void main(String[] args) {
10 |
11 | Alien a1 = new Alien();
12 | a1.setAid(101);
13 | a1.setAname("Navin");
14 | a1.setTech("Java");
15 |
16 | SessionFactory sf = new Configuration()
17 | .configure()
18 | .addAnnotatedClass(com.telusko.Alien.class)
19 | .buildSessionFactory();
20 |
21 | Session session = sf.openSession();
22 |
23 | Transaction transaction = session.beginTransaction();
24 | session.persist(a1);
25 | transaction.commit();
26 | session.close();
27 | sf.close();
28 |
29 |
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/HibProj-Le10/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le10/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | create
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le11/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le11/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le11/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le11/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le11/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le11/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le11/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le11/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Alien {
8 |
9 | @Id
10 | private int aid;
11 | private String aname;
12 | private String tech;
13 |
14 |
15 | public Laptop getLaptop() {
16 | return laptop;
17 | }
18 |
19 | public void setLaptop(Laptop laptop) {
20 | this.laptop = laptop;
21 | }
22 |
23 | private Laptop laptop;
24 |
25 | public int getAid() {
26 | return aid;
27 | }
28 |
29 | public void setAid(int aid) {
30 | this.aid = aid;
31 | }
32 |
33 | public String getTech() {
34 | return tech;
35 | }
36 |
37 | public void setTech(String tech) {
38 | this.tech = tech;
39 | }
40 |
41 | public String getAname() {
42 | return aname;
43 | }
44 |
45 | public void setAname(String aname) {
46 | this.aname = aname;
47 | }
48 |
49 |
50 | @Override
51 | public String toString() {
52 | return "Alien{" +
53 | "aid=" + aid +
54 | ", aname='" + aname + '\'' +
55 | ", tech='" + tech + '\'' +
56 | ", laptop=" + laptop +
57 | '}';
58 | }
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/HibProj-Le11/src/main/java/com/telusko/Laptop.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Embeddable;
4 |
5 | @Embeddable
6 | public class Laptop {
7 | private String brand;
8 | private String model;
9 | private int ram;
10 |
11 |
12 | public void setModel(String model) {
13 | this.model = model;
14 | }
15 |
16 |
17 | public void setRam(int ram) {
18 | this.ram = ram;
19 | }
20 |
21 | public void setBrand(String brand) {
22 | this.brand = brand;
23 | }
24 |
25 | public String getBrand() {
26 | return brand;
27 | }
28 |
29 | public int getRam() {
30 | return ram;
31 | }
32 |
33 | public String getModel() {
34 | return model;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Laptop{" +
41 | "brand='" + brand + '\'' +
42 | ", model='" + model + '\'' +
43 | ", ram=" + ram +
44 | '}';
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/HibProj-Le11/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | public class Main {
9 | public static void main(String[] args) {
10 |
11 | Laptop l1 = new Laptop();
12 | l1.setBrand("Asus");
13 | l1.setModel("Rog");
14 | l1.setRam(16);
15 |
16 |
17 | Alien a1 = new Alien();
18 | a1.setAid(101);
19 | a1.setAname("Navin");
20 | a1.setTech("Java");
21 | a1.setLaptop(l1);
22 |
23 | SessionFactory sf = new Configuration()
24 | .configure()
25 | .addAnnotatedClass(com.telusko.Alien.class)
26 | .buildSessionFactory();
27 |
28 | Session session = sf.openSession();
29 |
30 | Transaction transaction = session.beginTransaction();
31 | session.persist(a1);
32 | transaction.commit();
33 |
34 | Alien a2 = session.get(Alien.class, 101);
35 | System.out.println(a2);
36 | session.close();
37 | sf.close();
38 |
39 |
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/HibProj-Le11/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le11/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | create
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le13/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le13/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le13/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le13/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le13/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le13/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le13/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le13/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 | import jakarta.persistence.OneToOne;
6 |
7 | @Entity
8 | public class Alien {
9 |
10 | @Id
11 | private int aid;
12 | private String aname;
13 | private String tech;
14 | @OneToOne
15 | private Laptop laptop;
16 |
17 | public Laptop getLaptop() {
18 | return laptop;
19 | }
20 |
21 | public void setLaptop(Laptop laptop) {
22 | this.laptop = laptop;
23 | }
24 |
25 |
26 | public int getAid() {
27 | return aid;
28 | }
29 |
30 | public void setAid(int aid) {
31 | this.aid = aid;
32 | }
33 |
34 | public String getTech() {
35 | return tech;
36 | }
37 |
38 | public void setTech(String tech) {
39 | this.tech = tech;
40 | }
41 |
42 | public String getAname() {
43 | return aname;
44 | }
45 |
46 | public void setAname(String aname) {
47 | this.aname = aname;
48 | }
49 |
50 |
51 | @Override
52 | public String toString() {
53 | return "Alien{" +
54 | "aid=" + aid +
55 | ", aname='" + aname + '\'' +
56 | ", tech='" + tech + '\'' +
57 | ", laptop=" + laptop +
58 | '}';
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/HibProj-Le13/src/main/java/com/telusko/Laptop.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Laptop {
8 |
9 | @Id
10 | private int lid;
11 | private String brand;
12 | private String model;
13 | private int ram;
14 |
15 | public int getLid() {
16 | return lid;
17 | }
18 |
19 | public void setLid(int lid) {
20 | this.lid = lid;
21 | }
22 |
23 |
24 | public void setModel(String model) {
25 | this.model = model;
26 | }
27 |
28 |
29 | public void setRam(int ram) {
30 | this.ram = ram;
31 | }
32 |
33 | public void setBrand(String brand) {
34 | this.brand = brand;
35 | }
36 |
37 | public String getBrand() {
38 | return brand;
39 | }
40 |
41 | public int getRam() {
42 | return ram;
43 | }
44 |
45 | public String getModel() {
46 | return model;
47 | }
48 |
49 |
50 | @Override
51 | public String toString() {
52 | return "Laptop{" +
53 | "lid=" + lid +
54 | ", brand='" + brand + '\'' +
55 | ", model='" + model + '\'' +
56 | ", ram=" + ram +
57 | '}';
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/HibProj-Le13/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | public class Main {
9 | public static void main(String[] args) {
10 |
11 | Laptop l1 = new Laptop();
12 | l1.setLid(1);
13 | l1.setBrand("Asus");
14 | l1.setModel("Rog");
15 | l1.setRam(16);
16 |
17 |
18 | Alien a1 = new Alien();
19 | a1.setAid(101);
20 | a1.setAname("Navin");
21 | a1.setTech("Java");
22 | a1.setLaptop(l1);
23 |
24 | SessionFactory sf = new Configuration()
25 | .configure()
26 | .addAnnotatedClass(com.telusko.Alien.class)
27 | .addAnnotatedClass(com.telusko.Laptop.class)
28 | .buildSessionFactory();
29 |
30 | Session session = sf.openSession();
31 |
32 | Transaction transaction = session.beginTransaction();
33 | session.persist(l1);
34 | session.persist(a1);
35 | transaction.commit();
36 |
37 | Alien a2 = session.get(Alien.class, 101);
38 | System.out.println(a2);
39 | session.close();
40 | sf.close();
41 |
42 |
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/HibProj-Le13/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le13/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | create
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le14/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le14/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le14/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le14/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le14/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le14/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le14/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le14/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 | import jakarta.persistence.OneToMany;
6 |
7 | import java.util.List;
8 |
9 | @Entity
10 | public class Alien {
11 |
12 | @Id
13 | private int aid;
14 | private String aname;
15 | private String tech;
16 | @OneToMany(mappedBy = "alien")
17 | private List laptops;
18 |
19 | public List getLaptops() {
20 | return laptops;
21 | }
22 |
23 | public void setLaptops(List laptops) {
24 | this.laptops = laptops;
25 | }
26 |
27 | public int getAid() {
28 | return aid;
29 | }
30 |
31 | public void setAid(int aid) {
32 | this.aid = aid;
33 | }
34 |
35 | public String getTech() {
36 | return tech;
37 | }
38 |
39 | public void setTech(String tech) {
40 | this.tech = tech;
41 | }
42 |
43 | public String getAname() {
44 | return aname;
45 | }
46 |
47 | public void setAname(String aname) {
48 | this.aname = aname;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | return "Alien{" +
54 | "aid=" + aid +
55 | ", aname='" + aname + '\'' +
56 | ", tech='" + tech + '\'' +
57 | ", laptops=" + laptops +
58 | '}';
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/HibProj-Le14/src/main/java/com/telusko/Laptop.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 | import jakarta.persistence.ManyToOne;
6 |
7 | @Entity
8 | public class Laptop {
9 |
10 | @Id
11 | private int lid;
12 | private String brand;
13 | private String model;
14 | private int ram;
15 | @ManyToOne
16 | private Alien alien;
17 |
18 | public Alien getAlien() {
19 | return alien;
20 | }
21 |
22 | public void setAlien(Alien alien) {
23 | this.alien = alien;
24 | }
25 |
26 | public int getLid() {
27 | return lid;
28 | }
29 |
30 | public void setLid(int lid) {
31 | this.lid = lid;
32 | }
33 |
34 |
35 | public void setModel(String model) {
36 | this.model = model;
37 | }
38 |
39 |
40 | public void setRam(int ram) {
41 | this.ram = ram;
42 | }
43 |
44 | public void setBrand(String brand) {
45 | this.brand = brand;
46 | }
47 |
48 | public String getBrand() {
49 | return brand;
50 | }
51 |
52 | public int getRam() {
53 | return ram;
54 | }
55 |
56 | public String getModel() {
57 | return model;
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return "Laptop{" +
63 | "lid=" + lid +
64 | ", brand='" + brand + '\'' +
65 | ", model='" + model + '\'' +
66 | ", ram=" + ram +
67 | '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/HibProj-Le14/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | import java.util.Arrays;
9 |
10 | public class Main {
11 | public static void main(String[] args) {
12 |
13 | Laptop l1 = new Laptop();
14 | l1.setLid(1);
15 | l1.setBrand("Asus");
16 | l1.setModel("Rog");
17 | l1.setRam(16);
18 |
19 |
20 | Laptop l2 = new Laptop();
21 | l2.setLid(2);
22 | l2.setBrand("Dell");
23 | l2.setModel("XPS");
24 | l2.setRam(32);
25 |
26 | Alien a1 = new Alien();
27 | a1.setAid(101);
28 | a1.setAname("Navin");
29 | a1.setTech("Java");
30 | a1.setLaptops(Arrays.asList(l1, l2));
31 |
32 | l1.setAlien(a1);
33 | l2.setAlien(a1);
34 |
35 | SessionFactory sf = new Configuration()
36 | .configure()
37 | .addAnnotatedClass(com.telusko.Alien.class)
38 | .addAnnotatedClass(com.telusko.Laptop.class)
39 | .buildSessionFactory();
40 |
41 | Session session = sf.openSession();
42 |
43 | Transaction transaction = session.beginTransaction();
44 | session.persist(l1);
45 | session.persist(l2);
46 | session.persist(a1);
47 | transaction.commit();
48 |
49 | Alien a2 = session.get(Alien.class, 101);
50 | System.out.println(a2);
51 | session.close();
52 | sf.close();
53 |
54 |
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/HibProj-Le14/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le14/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | create
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le15/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le15/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le15/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le15/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le15/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le15/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le15/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le15/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 | import jakarta.persistence.ManyToMany;
6 | import jakarta.persistence.OneToMany;
7 |
8 | import java.util.List;
9 |
10 | @Entity
11 | public class Alien {
12 |
13 | @Id
14 | private int aid;
15 | private String aname;
16 | private String tech;
17 | @ManyToMany
18 | private List laptops;
19 |
20 | public List getLaptops() {
21 | return laptops;
22 | }
23 |
24 | public void setLaptops(List laptops) {
25 | this.laptops = laptops;
26 | }
27 |
28 | public int getAid() {
29 | return aid;
30 | }
31 |
32 | public void setAid(int aid) {
33 | this.aid = aid;
34 | }
35 |
36 | public String getTech() {
37 | return tech;
38 | }
39 |
40 | public void setTech(String tech) {
41 | this.tech = tech;
42 | }
43 |
44 | public String getAname() {
45 | return aname;
46 | }
47 |
48 | public void setAname(String aname) {
49 | this.aname = aname;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return "Alien{" +
55 | "aid=" + aid +
56 | ", aname='" + aname + '\'' +
57 | ", tech='" + tech + '\'' +
58 | ", laptops=" + laptops +
59 | '}';
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/HibProj-Le15/src/main/java/com/telusko/Laptop.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 | import jakarta.persistence.ManyToMany;
6 |
7 | import java.util.List;
8 |
9 | @Entity
10 | public class Laptop {
11 |
12 | @Id
13 | private int lid;
14 | private String brand;
15 | private String model;
16 | private int ram;
17 |
18 | @ManyToMany(mappedBy = "laptops")
19 | private List aliens;
20 | public List getAliens() {
21 | return aliens;
22 | }
23 |
24 | public void setAliens(List aliens) {
25 | this.aliens = aliens;
26 | }
27 |
28 |
29 | public int getLid() {
30 | return lid;
31 | }
32 |
33 | public void setLid(int lid) {
34 | this.lid = lid;
35 | }
36 |
37 |
38 | public void setModel(String model) {
39 | this.model = model;
40 | }
41 |
42 |
43 | public void setRam(int ram) {
44 | this.ram = ram;
45 | }
46 |
47 | public void setBrand(String brand) {
48 | this.brand = brand;
49 | }
50 |
51 | public String getBrand() {
52 | return brand;
53 | }
54 |
55 | public int getRam() {
56 | return ram;
57 | }
58 |
59 | public String getModel() {
60 | return model;
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return "Laptop{" +
66 | "lid=" + lid +
67 | ", brand='" + brand + '\'' +
68 | ", model='" + model + '\'' +
69 | ", ram=" + ram +
70 | '}';
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/HibProj-Le15/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | import java.util.Arrays;
9 |
10 | public class Main {
11 | public static void main(String[] args) {
12 |
13 | Laptop l1 = new Laptop();
14 | l1.setLid(1);
15 | l1.setBrand("Asus");
16 | l1.setModel("Rog");
17 | l1.setRam(16);
18 |
19 |
20 | Laptop l2 = new Laptop();
21 | l2.setLid(2);
22 | l2.setBrand("Dell");
23 | l2.setModel("XPS");
24 | l2.setRam(32);
25 |
26 | Laptop l3 = new Laptop();
27 | l3.setLid(3);
28 | l3.setBrand("Apple");
29 | l3.setModel("Macbook air");
30 | l3.setRam(8);
31 |
32 | Alien a1 = new Alien();
33 | a1.setAid(101);
34 | a1.setAname("Navin");
35 | a1.setTech("Java");
36 |
37 |
38 | Alien a2 = new Alien();
39 | a2.setAid(102);
40 | a2.setAname("Harsh");
41 | a2.setTech("Python");
42 |
43 |
44 | Alien a3 = new Alien();
45 | a3.setAid(103);
46 | a3.setAname("Kiran");
47 | a3.setTech("AI");
48 |
49 |
50 | a1.setLaptops(Arrays.asList(l1, l2));
51 | a2.setLaptops(Arrays.asList(l2, l3));
52 | a3.setLaptops(Arrays.asList(l1));
53 |
54 |
55 | l1.setAliens(Arrays.asList(a1, a3));
56 | l2.setAliens(Arrays.asList(a1, a2));
57 | l3.setAliens(Arrays.asList(a2));
58 |
59 |
60 | SessionFactory sf = new Configuration()
61 | .configure()
62 | .addAnnotatedClass(com.telusko.Alien.class)
63 | .addAnnotatedClass(com.telusko.Laptop.class)
64 | .buildSessionFactory();
65 |
66 | Session session = sf.openSession();
67 |
68 | Transaction transaction = session.beginTransaction();
69 | session.persist(l1);
70 | session.persist(l2);
71 | session.persist(l3);
72 |
73 | session.persist(a1);
74 | session.persist(a2);
75 | session.persist(a3);
76 |
77 | transaction.commit();
78 |
79 | Alien a5 = session.get(Alien.class, 102);
80 | System.out.println(a5);
81 | session.close();
82 | sf.close();
83 |
84 |
85 | }
86 |
87 | }
--------------------------------------------------------------------------------
/HibProj-Le15/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le15/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | create
10 | true
11 | true
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le16/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le16/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le16/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le16/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le16/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le16/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le16/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le16/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.FetchType;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.OneToMany;
7 |
8 | import java.util.List;
9 |
10 | @Entity
11 | public class Alien {
12 |
13 | @Id
14 | private int aid;
15 | private String aname;
16 | private String tech;
17 | @OneToMany(fetch = FetchType.EAGER)
18 | private List laptops;
19 |
20 | public List getLaptops() {
21 | return laptops;
22 | }
23 |
24 | public void setLaptops(List laptops) {
25 | this.laptops = laptops;
26 | }
27 |
28 | public int getAid() {
29 | return aid;
30 | }
31 |
32 | public void setAid(int aid) {
33 | this.aid = aid;
34 | }
35 |
36 | public String getTech() {
37 | return tech;
38 | }
39 |
40 | public void setTech(String tech) {
41 | this.tech = tech;
42 | }
43 |
44 | public String getAname() {
45 | return aname;
46 | }
47 |
48 | public void setAname(String aname) {
49 | this.aname = aname;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return "Alien{" +
55 | "aid=" + aid +
56 | ", aname='" + aname + '\'' +
57 | ", tech='" + tech + '\'' +
58 | ", laptops=" + laptops +
59 | '}';
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/HibProj-Le16/src/main/java/com/telusko/Laptop.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Laptop {
8 |
9 | @Id
10 | private int lid;
11 | private String brand;
12 | private String model;
13 | private int ram;
14 |
15 |
16 | public int getLid() {
17 | return lid;
18 | }
19 |
20 | public void setLid(int lid) {
21 | this.lid = lid;
22 | }
23 |
24 |
25 | public void setModel(String model) {
26 | this.model = model;
27 | }
28 |
29 |
30 | public void setRam(int ram) {
31 | this.ram = ram;
32 | }
33 |
34 | public void setBrand(String brand) {
35 | this.brand = brand;
36 | }
37 |
38 | public String getBrand() {
39 | return brand;
40 | }
41 |
42 | public int getRam() {
43 | return ram;
44 | }
45 |
46 | public String getModel() {
47 | return model;
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | return "Laptop{" +
53 | "lid=" + lid +
54 | ", brand='" + brand + '\'' +
55 | ", model='" + model + '\'' +
56 | ", ram=" + ram +
57 | '}';
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/HibProj-Le16/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.Transaction;
6 | import org.hibernate.cfg.Configuration;
7 |
8 | import java.util.Arrays;
9 |
10 | public class Main {
11 | public static void main(String[] args) {
12 |
13 | Laptop l1 = new Laptop();
14 | l1.setLid(1);
15 | l1.setBrand("Asus");
16 | l1.setModel("Rog");
17 | l1.setRam(16);
18 |
19 |
20 | Laptop l2 = new Laptop();
21 | l2.setLid(2);
22 | l2.setBrand("Dell");
23 | l2.setModel("XPS");
24 | l2.setRam(32);
25 |
26 | Laptop l3 = new Laptop();
27 | l3.setLid(3);
28 | l3.setBrand("Apple");
29 | l3.setModel("Macbook air");
30 | l3.setRam(8);
31 |
32 | Alien a1 = new Alien();
33 | a1.setAid(101);
34 | a1.setAname("Navin");
35 | a1.setTech("Java");
36 |
37 |
38 | Alien a2 = new Alien();
39 | a2.setAid(102);
40 | a2.setAname("Harsh");
41 | a2.setTech("Python");
42 |
43 |
44 | a1.setLaptops(Arrays.asList(l1, l2));
45 | a2.setLaptops(Arrays.asList(l3));
46 |
47 |
48 | SessionFactory sf = new Configuration()
49 | .configure()
50 | .addAnnotatedClass(com.telusko.Alien.class)
51 | .addAnnotatedClass(com.telusko.Laptop.class)
52 | .buildSessionFactory();
53 |
54 | Session session = sf.openSession();
55 |
56 | Transaction transaction = session.beginTransaction();
57 | session.persist(l1);
58 | session.persist(l2);
59 | session.persist(l3);
60 |
61 | session.persist(a1);
62 | session.persist(a2);
63 |
64 | transaction.commit();
65 |
66 |
67 | session.close();
68 |
69 | Session session1 = sf.openSession();
70 |
71 | Alien a5 = session1.get(Alien.class, 101);
72 | // System.out.println(a5);
73 | session1.close();
74 | sf.close();
75 |
76 |
77 | }
78 |
79 | }
--------------------------------------------------------------------------------
/HibProj-Le16/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le16/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | create
10 | true
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le19/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le19/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le19/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le19/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le19/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le19/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le19/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le19/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.FetchType;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.OneToMany;
7 |
8 | import java.util.List;
9 |
10 | @Entity
11 | public class Alien {
12 |
13 | @Id
14 | private int aid;
15 | private String aname;
16 | private String tech;
17 | @OneToMany(fetch = FetchType.EAGER)
18 | private List laptops;
19 |
20 | public List getLaptops() {
21 | return laptops;
22 | }
23 |
24 | public void setLaptops(List laptops) {
25 | this.laptops = laptops;
26 | }
27 |
28 | public int getAid() {
29 | return aid;
30 | }
31 |
32 | public void setAid(int aid) {
33 | this.aid = aid;
34 | }
35 |
36 | public String getTech() {
37 | return tech;
38 | }
39 |
40 | public void setTech(String tech) {
41 | this.tech = tech;
42 | }
43 |
44 | public String getAname() {
45 | return aname;
46 | }
47 |
48 | public void setAname(String aname) {
49 | this.aname = aname;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return "Alien{" +
55 | "aid=" + aid +
56 | ", aname='" + aname + '\'' +
57 | ", tech='" + tech + '\'' +
58 | ", laptops=" + laptops +
59 | '}';
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/HibProj-Le19/src/main/java/com/telusko/Laptop.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Laptop {
8 |
9 | @Id
10 | private int lid;
11 | private String brand;
12 | private String model;
13 | private int ram;
14 |
15 |
16 | public int getLid() {
17 | return lid;
18 | }
19 |
20 | public void setLid(int lid) {
21 | this.lid = lid;
22 | }
23 |
24 |
25 | public void setModel(String model) {
26 | this.model = model;
27 | }
28 |
29 |
30 | public void setRam(int ram) {
31 | this.ram = ram;
32 | }
33 |
34 | public void setBrand(String brand) {
35 | this.brand = brand;
36 | }
37 |
38 | public String getBrand() {
39 | return brand;
40 | }
41 |
42 | public int getRam() {
43 | return ram;
44 | }
45 |
46 | public String getModel() {
47 | return model;
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | return "Laptop{" +
53 | "lid=" + lid +
54 | ", brand='" + brand + '\'' +
55 | ", model='" + model + '\'' +
56 | ", ram=" + ram +
57 | '}';
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/HibProj-Le19/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.cfg.Configuration;
6 | import org.hibernate.query.Query;
7 |
8 | import java.util.List;
9 |
10 | public class Main {
11 | public static void main(String[] args) {
12 |
13 |
14 | SessionFactory sf = new Configuration()
15 | .configure()
16 | .addAnnotatedClass(com.telusko.Laptop.class)
17 | .buildSessionFactory();
18 |
19 | Session session = sf.openSession();
20 |
21 | // Select * from laptop where ram=32 ->SQL
22 | // from Laptop where ram=32 -> HQL
23 |
24 |
25 | Query query = session.createQuery("from Laptop where ram=32");
26 | List laptops = query.getResultList();
27 |
28 |
29 | // Laptop l1=session.get(Laptop.class, 3);
30 | System.out.println(laptops);
31 | session.close();
32 |
33 | sf.close();
34 |
35 |
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/HibProj-Le19/src/main/java/com/telusko/Student.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Student {
8 | @Id
9 | private int rollNo;
10 | private String sName;
11 | private int sAge;
12 |
13 | public int getsAge() {
14 | return sAge;
15 | }
16 |
17 | public void setsAge(int sAge) {
18 | this.sAge = sAge;
19 | }
20 |
21 | public String getsName() {
22 | return sName;
23 | }
24 |
25 | public void setsName(String sName) {
26 | this.sName = sName;
27 | }
28 |
29 | public int getRollNo() {
30 | return rollNo;
31 | }
32 |
33 | public void setRollNo(int rollNo) {
34 | this.rollNo = rollNo;
35 | }
36 |
37 |
38 | @Override
39 | public String toString() {
40 | return "Student{" +
41 | "rollNo=" + rollNo +
42 | ", sName='" + sName + '\'' +
43 | ", sAge=" + sAge +
44 | '}';
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/HibProj-Le19/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.postgresql.Driver
4 | jdbc:postgresql://localhost:5432/telusko
5 | postgres
6 | 12345678
7 |
8 | org.hibernate.dialect.PostgreSQLDialect
9 | update
10 | true
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le20/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/HibProj-Le20/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/HibProj-Le20/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HibProj-Le20/.idea/material_theme_project_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HibProj-Le20/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HibProj-Le20/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HibProj-Le20/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.telusko
8 | HibProj
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 23
13 | 23
14 | UTF-8
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.postgresql
22 | postgresql
23 | 42.7.3
24 |
25 |
26 |
27 | org.hibernate.orm
28 | hibernate-core
29 | 6.6.3.Final
30 |
31 |
32 |
--------------------------------------------------------------------------------
/HibProj-Le20/src/main/java/com/telusko/Alien.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.FetchType;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.OneToMany;
7 |
8 | import java.util.List;
9 |
10 | @Entity
11 | public class Alien {
12 |
13 | @Id
14 | private int aid;
15 | private String aname;
16 | private String tech;
17 | @OneToMany(fetch = FetchType.EAGER)
18 | private List laptops;
19 |
20 | public List getLaptops() {
21 | return laptops;
22 | }
23 |
24 | public void setLaptops(List laptops) {
25 | this.laptops = laptops;
26 | }
27 |
28 | public int getAid() {
29 | return aid;
30 | }
31 |
32 | public void setAid(int aid) {
33 | this.aid = aid;
34 | }
35 |
36 | public String getTech() {
37 | return tech;
38 | }
39 |
40 | public void setTech(String tech) {
41 | this.tech = tech;
42 | }
43 |
44 | public String getAname() {
45 | return aname;
46 | }
47 |
48 | public void setAname(String aname) {
49 | this.aname = aname;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return "Alien{" +
55 | "aid=" + aid +
56 | ", aname='" + aname + '\'' +
57 | ", tech='" + tech + '\'' +
58 | ", laptops=" + laptops +
59 | '}';
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/HibProj-Le20/src/main/java/com/telusko/Laptop.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.Id;
5 |
6 | @Entity
7 | public class Laptop {
8 |
9 | @Id
10 | private int lid;
11 | private String brand;
12 | private String model;
13 | private int ram;
14 |
15 |
16 | public int getLid() {
17 | return lid;
18 | }
19 |
20 | public void setLid(int lid) {
21 | this.lid = lid;
22 | }
23 |
24 |
25 | public void setModel(String model) {
26 | this.model = model;
27 | }
28 |
29 |
30 | public void setRam(int ram) {
31 | this.ram = ram;
32 | }
33 |
34 | public void setBrand(String brand) {
35 | this.brand = brand;
36 | }
37 |
38 | public String getBrand() {
39 | return brand;
40 | }
41 |
42 | public int getRam() {
43 | return ram;
44 | }
45 |
46 | public String getModel() {
47 | return model;
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | return "Laptop{" +
53 | "lid=" + lid +
54 | ", brand='" + brand + '\'' +
55 | ", model='" + model + '\'' +
56 | ", ram=" + ram +
57 | '}';
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/HibProj-Le20/src/main/java/com/telusko/Main.java:
--------------------------------------------------------------------------------
1 | package com.telusko;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.SessionFactory;
5 | import org.hibernate.cfg.Configuration;
6 | import org.hibernate.query.Query;
7 |
8 | import java.util.List;
9 |
10 | public class Main {
11 | public static void main(String[] args) {
12 |
13 |
14 | SessionFactory sf = new Configuration()
15 | .configure()
16 | .addAnnotatedClass(com.telusko.Laptop.class)
17 | .buildSessionFactory();
18 |
19 | Session session = sf.openSession();
20 |
21 | // Select * from laptop where ram=32 ->SQL
22 | // from Laptop where ram=32 -> HQL
23 |
24 | String brand = "Asus";
25 |
26 | // Query query = session.createQuery("from Laptop where brand like 'Asus' ");
27 |
28 | Query query = session.createQuery("select brand, model from Laptop where brand like ?1");
29 | query.setParameter(1, brand);
30 |
31 | // List laptops = query.getResultList();
32 | List