File tree Expand file tree Collapse file tree
maven/com.spring.hibernate/Spring-Hibernate
test-classes/com/pu/exp_8 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <classpath >
3+ <classpathentry kind =" src" output =" target/classes" path =" src/main/java" >
4+ <attributes >
5+ <attribute name =" optional" value =" true" />
6+ <attribute name =" maven.pomderived" value =" true" />
7+ </attributes >
8+ </classpathentry >
9+ <classpathentry excluding =" **" kind =" src" output =" target/classes" path =" src/main/resources" >
10+ <attributes >
11+ <attribute name =" maven.pomderived" value =" true" />
12+ <attribute name =" optional" value =" true" />
13+ </attributes >
14+ </classpathentry >
15+ <classpathentry kind =" src" output =" target/test-classes" path =" src/test/java" >
16+ <attributes >
17+ <attribute name =" test" value =" true" />
18+ <attribute name =" optional" value =" true" />
19+ <attribute name =" maven.pomderived" value =" true" />
20+ </attributes >
21+ </classpathentry >
22+ <classpathentry excluding =" **" kind =" src" output =" target/test-classes" path =" src/test/resources" >
23+ <attributes >
24+ <attribute name =" test" value =" true" />
25+ <attribute name =" maven.pomderived" value =" true" />
26+ <attribute name =" optional" value =" true" />
27+ </attributes >
28+ </classpathentry >
29+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER" >
30+ <attributes >
31+ <attribute name =" module" value =" true" />
32+ <attribute name =" maven.pomderived" value =" true" />
33+ </attributes >
34+ </classpathentry >
35+ <classpathentry kind =" con" path =" org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" >
36+ <attributes >
37+ <attribute name =" maven.pomderived" value =" true" />
38+ </attributes >
39+ </classpathentry >
40+ <classpathentry kind =" output" path =" target/classes" />
41+ </classpath >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <projectDescription >
3+ <name >exp_8</name >
4+ <comment ></comment >
5+ <projects >
6+ </projects >
7+ <buildSpec >
8+ <buildCommand >
9+ <name >org.eclipse.jdt.core.javabuilder</name >
10+ <arguments >
11+ </arguments >
12+ </buildCommand >
13+ <buildCommand >
14+ <name >org.eclipse.m2e.core.maven2Builder</name >
15+ <arguments >
16+ </arguments >
17+ </buildCommand >
18+ <buildCommand >
19+ <name >org.hibernate.eclipse.console.hibernateBuilder</name >
20+ <arguments >
21+ </arguments >
22+ </buildCommand >
23+ </buildSpec >
24+ <natures >
25+ <nature >org.eclipse.jdt.core.javanature</nature >
26+ <nature >org.eclipse.m2e.core.maven2Nature</nature >
27+ <nature >org.hibernate.eclipse.console.hibernateNature</nature >
28+ </natures >
29+ </projectDescription >
Original file line number Diff line number Diff line change 1+ eclipse.preferences.version =1
2+ encoding//src/main/java =UTF-8
3+ encoding//src/test/java =UTF-8
4+ encoding/<project>=UTF-8
Original file line number Diff line number Diff line change 1+ eclipse.preferences.version =1
2+ org.eclipse.jdt.core.compiler.codegen.targetPlatform =1.8
3+ org.eclipse.jdt.core.compiler.compliance =1.8
4+ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures =disabled
5+ org.eclipse.jdt.core.compiler.problem.forbiddenReference =warning
6+ org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures =ignore
7+ org.eclipse.jdt.core.compiler.release =disabled
8+ org.eclipse.jdt.core.compiler.source =1.8
Original file line number Diff line number Diff line change 1+ activeProfiles =
2+ eclipse.preferences.version =1
3+ resolveWorkspaceProjects =true
4+ version =1
Original file line number Diff line number Diff line change 1+ default.configuration =exp_8
2+ eclipse.preferences.version =1
3+ hibernate3.enabled =true
Original file line number Diff line number Diff line change 1+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+
5+ <groupId >com.spring.hibernate</groupId >
6+ <artifactId >Spring-Hibernate</artifactId >
7+ <version >0.0.1-SNAPSHOT</version >
8+ <packaging >jar</packaging >
9+
10+ <name >Spring-Hibernate</name >
11+ <url >http://maven.apache.org</url >
12+
13+ <properties >
14+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
15+ </properties >
16+
17+ <dependencies >
18+ <dependency >
19+ <groupId >junit</groupId >
20+ <artifactId >junit</artifactId >
21+ <version >3.8.1</version >
22+ <scope >test</scope >
23+ </dependency >
24+
25+ <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
26+ <dependency >
27+ <groupId >org.hibernate</groupId >
28+ <artifactId >hibernate-core</artifactId >
29+ <version >4.2.7.Final</version >
30+ </dependency >
31+
32+
33+
34+ <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
35+ <dependency >
36+ <groupId >mysql</groupId >
37+ <artifactId >mysql-connector-java</artifactId >
38+ <version >5.1.21</version >
39+ </dependency >
40+
41+ </dependencies >
42+ </project >
Original file line number Diff line number Diff line change 1+ package com .pu .exp_8 ;
2+
3+ import org .hibernate .Session ;
4+ import org .hibernate .SessionFactory ;
5+ import org .hibernate .Transaction ;
6+ import org .hibernate .cfg .Configuration ;
7+ /**
8+ * Hello world!
9+ *
10+ */
11+ public class App
12+ {
13+ public static void main ( String [] args )
14+ {
15+ Student student = new Student ();
16+ student .setRoll (1 );
17+ student .setName ("god" );
18+ student .setMarks (100 );
19+ //1. create Configuration object
20+ Configuration configuration =new Configuration ().configure ().addAnnotatedClass (Student .class );
21+ //2. create Session Factroy object
22+ SessionFactory sessionFactory =configuration .buildSessionFactory ();
23+ //3. Create Session object
24+ Session session =sessionFactory .openSession ();
25+ //4. Begin your transaction
26+ Transaction transaction =session .beginTransaction ();
27+ //5.Save your object to database
28+ session .save (student );
29+ //6/ Commit your transaction
30+ transaction .commit ();
31+ session .close ();
32+ sessionFactory .close ();
33+ }
34+ }
35+
36+
Original file line number Diff line number Diff line change 1+ package com .pu .exp_8 ;
2+
3+ import javax .persistence .Entity ;
4+ import javax .persistence .Id ;
5+
6+ @ Entity
7+ public class Student {
8+ @ Id
9+ private int roll ;
10+ private String name ;
11+ private int marks ;
12+ public int getRoll () {
13+ return roll ;
14+ }
15+ public void setRoll (int roll ) {
16+ this .roll = roll ;
17+ }
18+ public String getName () {
19+ return name ;
20+ }
21+ public void setName (String name ) {
22+ this .name = name ;
23+ }
24+ public int getMarks () {
25+ return marks ;
26+ }
27+ public void setMarks (int marks ) {
28+ this .marks = marks ;
29+ }
30+
31+
32+ }
33+
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
3+ "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
4+ <hibernate-configuration >
5+ <session-factory name =" hi" />
6+ </hibernate-configuration >
You can’t perform that action at this time.
0 commit comments