title: Hibernate, data is not inserting into table
body: <p>I'm a newbie to hibernate. I'm trying to insert data into table. It's only creating the tables but not inserting the data into table. I'm not sure where I'm doing wrong.</p>
  
  <p>Any help would be appreciable. </p>
  
  <p><strong>UserDetails:</strong></p>
  
  <pre><code>package org.com.etown.onetoone;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.OneToOne;
  
  @Entity
  public class UserDetails {
      @Id @GeneratedValue(strategy = GenerationType.AUTO)
      private int userid;
      private String userName;    
  
      public int getUserid() {
          return userid;
      }
      public void setUserid(int userid) {
          this.userid = userid;
      }
      public String getUserName() {
          return userName;
      }
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
  }
  </code></pre>
  
  <p><strong>UserDetailsDao:</strong></p>
  
  <pre><code>package org.com.etown.onetoone;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  public class UserDatailsDao {
  
      public static void main(String[] args) {
  
          UserDetails user = new UserDetails();
          user.setUserName("george");
  
          SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
          Session session = sessionFactory.openSession();
          session.beginTransaction();
          session.save(user);
          session.getTransaction().commit();
          session.close();
  
  
      }
  
  }
  </code></pre>
  
  <p><strong>hibernate.cfg.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration SYSTEM 
  "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
     &lt;session-factory&gt;
     &lt;!-- Database connection settings --&gt;
     &lt;property name="connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;
     &lt;property name="connection.url"&gt;jdbc:postgresql://localhost:5432/etowndb&lt;/property&gt;
     &lt;property name="connection.username"&gt;postgres&lt;/property&gt;
     &lt;property name="connection.password"&gt;root&lt;/property&gt;
  
     &lt;!-- JDBC connection pool (use the built-in) --&gt;
     &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
    &lt;!-- SQL Dialect --&gt;
    &lt;property name="dialect"&gt;org.hibernate.dialect.PostgreSQL92Dialect&lt;/property&gt;
  
    &lt;!-- Disable the second level class --&gt;
    &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;
  
    &lt;!-- Echo all executed SQL to stdout --&gt;
    &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
    &lt;!-- Drop and re-creat the database schema on startup --&gt;
    &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;&lt;!-- update,create --&gt;  
  
    &lt;!-- Names of the annotated entity class --&gt;
    &lt;mapping class="org.com.etown.onetoone.UserDetails"/&gt;  
  
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><strong>Console Error:</strong></p>
  
  <pre><code>Oct 13, 2016 12:46:30 PM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {5.1.1.Final}
  Oct 13, 2016 12:46:30 PM org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: HHH000206: hibernate.properties not found
  Oct 13, 2016 12:46:30 PM org.hibernate.cfg.Environment buildBytecodeProvider
  INFO: HHH000021: Bytecode provider name : javassist
  Oct 13, 2016 12:46:30 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager &lt;clinit&gt;
  INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/etowndb]
  Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001001: Connection properties: {user=postgres, password=****}
  Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001003: Autocommit mode: false
  Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections &lt;init&gt;
  INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
  Oct 13, 2016 12:46:30 PM org.hibernate.dialect.Dialect &lt;init&gt;
  INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL92Dialect
  Oct 13, 2016 12:46:31 PM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation
  INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
  Oct 13, 2016 12:46:31 PM org.hibernate.type.BasicTypeRegistry register
  INFO: HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@7ffeac8e
  Oct 13, 2016 12:46:31 PM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
  INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@31c08b2e] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
  Oct 13, 2016 12:46:31 PM org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl processGetTableResults
  INFO: HHH000262: Table not found: UserDetails
  Oct 13, 2016 12:46:31 PM org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl processGetTableResults
  INFO: HHH000262: Table not found: UserDetails
  Hibernate: create table UserDetails (userid int4 not null, userName varchar(255), primary key (userid))
  Oct 13, 2016 12:46:31 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler logWarning
  WARN: SQL Warning Code: 0, SQLState: 00000
  Oct 13, 2016 12:46:31 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler logWarning
  WARN: CREATE TABLE / PRIMARY KEY will create implicit index "userdetails_pkey" for table "userdetails"
  Hibernate: select nextval ('hibernate_sequence')
  </code></pre>