Hibernate insert record and retrieve same data to console using Oracle Database
#Hibernate #insert one #record and #retrieve the same to console using #Oracle #Database #Create Hibernate application to insert one record and retrieve the same to console using Oracle Database: Here im using hibernate-distribution-3.6.5.Final-dist JDK 1.8 Oracle Database 10 Create Table (Employee) Open SqlPlus create table employee(eid number(5)primary key,firstname varchar(20),lastname varchar(20),email varchar(25)); Create the Project Folder "HibApp" Step 1) Create Bean Class (EmpBean.java) Step 2) configuration file (hibernate.cfg.xml) Oracle DB related Properties For Doctype search for *.cfg.xml in downloaded dist folder open any .cfg.xml file using editor and simply copy paste !DOCTYPE of that configuration file Step 3) mapping file (Empolyee.hbm.xml) to map Pojo class with Database table For Doctype search for *.hbm.xml in downloaded dist folder open any .hbm.xml file using editor and simply copy paste !DOCTYPE of that hibernate mapping file Step 4) Client java application (TestClient.java) Step 5) Download hibernate-distribution-3.6.5.Final-dist.zip file from https://sourceforge.net/projects/hibernate/files/hibernate3/3.6.5.Final/ extract to your preferred location Following Jars Need to be added to the classpath -hibernate3.jar; -antlr-2.7.6.jar; -commons-collections-3.1.jar; -dom4j-1.6.1.jar; -javassist-3.12.0.GA.jar; -jta-1.1.jar; -slf4j-api-1.6.1.jar; -hibernate-jpa-2.0-api-1.0.0.Final.jar; c:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar; 9 Jars Right CLick on My COmputer Select Properties CLick on Advanced System Settings Go to Advanced Tab Hit the Environment Variable Button add the above jars seperated by ; to the classpath Step 6) Compile .java files Error Occured So type cast to EmpBean like EmpBean eb1=(EmpBean)ses.load(EmpBean.class,233); Save the TestClient.java Then recompile .java file Successfully compiles Step 7) Run the TestClient application java TestClient //Proof of interface implemented class public final class SessionFactoryImpl implements SessionFactory, SessionFactoryImplementor { public final class SessionImpl extends AbstractSessionImpl implements EventSource, org.hibernate.classic.Session, org.hibernate.jdbc.JDBCContext.Context, LobCreationContext { /* member class not found */ class LockRequestImpl {}
#Hibernate #insert one #record and #retrieve the same to console using #Oracle #Database #Create Hibernate application to insert one record and retrieve the same to console using Oracle Database: Here im using hibernate-distribution-3.6.5.Final-dist JDK 1.8 Oracle Database 10 Create Table (Employee) Open SqlPlus create table employee(eid number(5)primary key,firstname varchar(20),lastname varchar(20),email varchar(25)); Create the Project Folder "HibApp" Step 1) Create Bean Class (EmpBean.java) Step 2) configuration file (hibernate.cfg.xml) Oracle DB related Properties For Doctype search for *.cfg.xml in downloaded dist folder open any .cfg.xml file using editor and simply copy paste !DOCTYPE of that configuration file Step 3) mapping file (Empolyee.hbm.xml) to map Pojo class with Database table For Doctype search for *.hbm.xml in downloaded dist folder open any .hbm.xml file using editor and simply copy paste !DOCTYPE of that hibernate mapping file Step 4) Client java application (TestClient.java) Step 5) Download hibernate-distribution-3.6.5.Final-dist.zip file from https://sourceforge.net/projects/hibernate/files/hibernate3/3.6.5.Final/ extract to your preferred location Following Jars Need to be added to the classpath -hibernate3.jar; -antlr-2.7.6.jar; -commons-collections-3.1.jar; -dom4j-1.6.1.jar; -javassist-3.12.0.GA.jar; -jta-1.1.jar; -slf4j-api-1.6.1.jar; -hibernate-jpa-2.0-api-1.0.0.Final.jar; c:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar; 9 Jars Right CLick on My COmputer Select Properties CLick on Advanced System Settings Go to Advanced Tab Hit the Environment Variable Button add the above jars seperated by ; to the classpath Step 6) Compile .java files Error Occured So type cast to EmpBean like EmpBean eb1=(EmpBean)ses.load(EmpBean.class,233); Save the TestClient.java Then recompile .java file Successfully compiles Step 7) Run the TestClient application java TestClient //Proof of interface implemented class public final class SessionFactoryImpl implements SessionFactory, SessionFactoryImplementor { public final class SessionImpl extends AbstractSessionImpl implements EventSource, org.hibernate.classic.Session, org.hibernate.jdbc.JDBCContext.Context, LobCreationContext { /* member class not found */ class LockRequestImpl {}