title: Invalid column name 'vehicle_userId': Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute statement
body: <pre><code>package model;
  
    import java.util.Date;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.OneToOne;
  import javax.persistence.Table;
  import javax.persistence.Temporal;
  import javax.persistence.TemporalType;
  
  @Entity
  @Table(name = "USERDETAILS")
  public class UserDetails {
      private int userId;
      private String userName;
      private Date joineddate;
      private String description;
      private Vehicle vehicle;
  
      @OneToOne
      public Vehicle getVehicle() {
          return vehicle;
      }
  
  
      public void setVehicle(Vehicle vehicle) {
          this.vehicle = vehicle;
      }
  
  
      public void setJoineddate(Date joineddate) {
          this.joineddate = joineddate;
      }
  
  
      @Temporal(TemporalType.DATE)
      public Date getJoineddate() {
          return joineddate;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      public int getUserId() {
          return userId;
      }
  
      public void setUserId(int userId) {
          this.userId = userId;
      }
  
      @Column(name = "User_Name")
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }   
  }
  </code></pre>
  
  <p>Here I am creating userdetails table</p>
  
  <pre><code>  package model;
  
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.GenerationType;
      import javax.persistence.Id;
  
      @Entity
      public class Vehicle {
          private int vehicleId;
          private String vehicleName;
  
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          @Column(name="userId")
          public int getVehicleId() {
              return vehicleId;
          }
  
          public void setVehicleId(int vehicleId) {
              this.vehicleId = vehicleId;
          }
  
          public String getVehicleName() {
              return vehicleName;
          }
  
          public void setVehicleName(String vehicleName) {
              this.vehicleName = vehicleName;
          }
  
      }
  </code></pre>
  
  <p>Here I am creating vehicle table using one to one mapping</p>
  
  <pre><code>package hibernate;
  
  import java.util.Date;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  //import model.Address;
  import model.UserDetails;
  import model.Vehicle;
  
  public class HibernateTest {
  
      public static void main(String[] args) {
          SessionFactory sessionFactory = new Configuration().configure()
                  .buildSessionFactory();
          Session session = sessionFactory.openSession();
  
          UserDetails user = new UserDetails();
          user.setUserName("bhagyasri");
          user.setDescription("bhagyasri's description");
          user.setJoineddate(new Date());
  
          Vehicle vehicle = new Vehicle();
          vehicle.setVehicleName("hero");
  
          user.setVehicle(vehicle);
  
          session.beginTransaction();
          session.save(user);
          session.save(vehicle);
  
          session.getTransaction().commit();
          session.close();
      }
  
  }
  </code></pre>
  
  <p>I am getting error like this </p>
  
  <pre><code>Jan 16, 2015 4:17:43 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  WARN: SQL Error: 207, SQLState: S0001
  Jan 16, 2015 4:17:43 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  ERROR: Invalid column name 'vehicle_userId'.
  Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute statement
      at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211)
  </code></pre>
  
  <p>Hibernate configuration</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;  
  &lt;!DOCTYPE hibernate-configuration PUBLIC  
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
            "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  
      &lt;session-factory&gt;
          &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.SQLServer2008Dialect&lt;/property&gt;
          &lt;property name="connection.url"&gt;jdbc:sqlserver://192.168.2.219\SQLEXPRESS;databaseName=train&lt;/property&gt;
          &lt;property name="connection.username"&gt;train&lt;/property&gt;
          &lt;property name="connection.password"&gt;tspl@123&lt;/property&gt;
          &lt;property name="connection.driver_class"&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;mapping class="model.UserDetails" /&gt;
          &lt;mapping class="model.Vehicle" /&gt;
  
      &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;  
  </code></pre>
  
  <p>this is my configuration file.. I am getting Invalid column name 'vehicle_userId': SQLGrammarException I am not getting what is the exact problem Any suggestions?</p>