title: org.hibernate.id.IdentifierGenerationException: null id generated for:class
body: <p>i am getting the following Exception while inserting into table Which has two dependencies</p>
  
  <p>look at my Entity classes these are auto generated</p>
  
  <p><strong>AssocTransportVehicleDriver</strong> </p>
  
  <pre><code>package com.rasvek.cg.entity;
  // Generated May 14, 2018 11:39:07 PM by Hibernate Tools 5.1.7.Final
  
  import javax.persistence.AttributeOverride;
  import javax.persistence.AttributeOverrides;
  import javax.persistence.Column;
  import javax.persistence.EmbeddedId;
  import javax.persistence.Entity;
  import javax.persistence.FetchType;
  import javax.persistence.JoinColumn;
  import javax.persistence.ManyToOne;
  import javax.persistence.Table;
  
  /**
   * AssocTransportVehicleDriver generated by hbm2java
   */
  @Entity
  @Table(name = "assoc_transport_vehicle_driver", catalog = "campus_guru_01")
  public class AssocTransportVehicleDriver implements java.io.Serializable {
  
      private AssocTransportVehicleDriverId id;
      private TransportDriverInfo transportDriverInfo;
      private TransportVehicleInfo transportVehicleInfo;
  
      public AssocTransportVehicleDriver() {
      }
  
      public AssocTransportVehicleDriver(AssocTransportVehicleDriverId id, TransportDriverInfo transportDriverInfo,
              TransportVehicleInfo transportVehicleInfo) {
          this.id = id;
          this.transportDriverInfo = transportDriverInfo;
          this.transportVehicleInfo = transportVehicleInfo;
      }
  
      @EmbeddedId
  
      @AttributeOverrides({
              @AttributeOverride(name = "vehicleId", column = @Column(name = "vehicle_id", nullable = false)),
              @AttributeOverride(name = "tdiId", column = @Column(name = "tdi_id", nullable = false)) })
      public AssocTransportVehicleDriverId getId() {
          return this.id;
      }
  
      public void setId(AssocTransportVehicleDriverId id) {
          this.id = id;
      }
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "tdi_id", nullable = false, insertable = false, updatable = false)
      public TransportDriverInfo getTransportDriverInfo() {
          return this.transportDriverInfo;
      }
  
      public void setTransportDriverInfo(TransportDriverInfo transportDriverInfo) {
          this.transportDriverInfo = transportDriverInfo;
      }
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "vehicle_id", nullable = false, insertable = false, updatable = false)
      public TransportVehicleInfo getTransportVehicleInfo() {
          return this.transportVehicleInfo;
      }
  
      public void setTransportVehicleInfo(TransportVehicleInfo transportVehicleInfo) {
          this.transportVehicleInfo = transportVehicleInfo;  
      }
  
  }
  </code></pre>
  
  <p>another <code>(@Embeddable)</code> class generated along with this class called </p>
  
  <p><strong>AssocTransportVehicleDriverId</strong> //what is the use of it</p>
  
  <pre><code>@Embeddable
  public class AssocTransportVehicleDriverId implements java.io.Serializable {
  
      private int vehicleId;
      private int tdiId;
  
      public AssocTransportVehicleDriverId() {
      }
  
      public AssocTransportVehicleDriverId(int vehicleId, int tdiId) {
          this.vehicleId = vehicleId;
          this.tdiId = tdiId;
      }
  
      @Column(name = "vehicle_id", nullable = false)
      public int getVehicleId() {
          return this.vehicleId;
      }
  
      public void setVehicleId(int vehicleId) {
          this.vehicleId = vehicleId;
      }
  
      @Column(name = "tdi_id", nullable = false)
      public int getTdiId() {
          return this.tdiId;
      }
  
      public void setTdiId(int tdiId) {
          this.tdiId = tdiId;
      }
  
      public boolean equals(Object other) {
          if ((this == other))
              return true;
          if ((other == null))
              return false;
          if (!(other instanceof AssocTransportVehicleDriverId))
              return false;
          AssocTransportVehicleDriverId castOther = (AssocTransportVehicleDriverId) other;
  
          return (this.getVehicleId() == castOther.getVehicleId()) &amp;&amp; (this.getTdiId() == castOther.getTdiId());
      }
  
      public int hashCode() {
          int result = 17;
  
          result = 37 * result + this.getVehicleId();
          result = 37 * result + this.getTdiId();
          return result;
      }
  
  }
  </code></pre>
  
  <p>when i try to insert into <code>AssocTransportVehicleDriver</code> the above Exception is occurring .do not know why ?</p>
  
  <p><strong>AssocTransportVehicleDriver table does not have any Id column in table but it as generated</strong> .</p>
  
  <p>please look at my query</p>
  
  <pre><code>                  AssocTransportVehicleDriver obj=null;
  
  
  
  
                      if(transportVehicleInfoId != 0 &amp;&amp; transportDriverInfoId != 0)
                      {
                          TransportVehicleInfo    transportVehicleInfo1 = new TransportVehicleInfo();
  
                          TransportDriverInfo transportDriverInfo1 = new TransportDriverInfo();
  
                          transportDriverInfo1.setTdiId(transportDriverInfoId);
                          transportVehicleInfo1.setVehicleId(transportDriverInfoId);
  
  
                          obj= new AssocTransportVehicleDriver();
  
                          obj.setTransportDriverInfo(transportDriverInfo1);
                          obj.setTransportVehicleInfo(transportVehicleInfo1);
                          res=service.addAssocDriverVehicle(obj);
                      }  
  
  
  
  @Override
      public boolean addAssocDriverVehicle(AssocTransportVehicleDriver  assocTransportVehicleDriver) {
           boolean success = false;
           try {
  
                  currentSession=sessionFactory.getCurrentSession();
                  currentSession.save(assocTransportVehicleDriver);     
                  success=true;  
           }       
           catch (Exception e) {
              e.printStackTrace();  
          }
  
          return success; 
      }     
  </code></pre>
  
  <p>please let me know why its happening. how to insert into  <code>AssocTransportVehicleDriver</code> ?</p>
  
  <p>i am very new to hibernate , forgive me if its silly one.</p>
  
  <p>thank you !.</p>