Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate@ oracle Express Edition (XE)

 
Gupta Saurabh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate Mapping file is :

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc racle:thin:@localhost:1521:xe</property>
<property name="hibernate.connection.username">SAURABH-PRACTICE</property>
<property name="hibernate.connection.password">sys123</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>

I was trying to insert a simple data inside a table (Contact).

try {
SessionFactory sessionFactory = new Configuration().configure()
.buildSessionFactory();
session = sessionFactory.openSession();
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(6);
contact.setFirstName("Alice");
contact.setLastName("Wonderland");
contact.setEmail("Alice.Wonderland@yahoo.com");
session.save(contact);
System.out.println("Done");
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
} finally {
session.flush();
session.close();
}

<<<<< Problem: It is going smoothly, but it is not inserting any data in the table and also not throwing any exception for the same. >>>>>>

Is there any problem with the OracleDialect?
should i use something else?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you just need to get and begin a Transaction, then commit it.

Mark
 
Gupta Saurabh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark.
I really appreciate that you have taken effort in answering the very simple question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic