title: How to handle org.hibernate.ObjectNotFoundException
body: <p>I am working on a Spring mvc app in which I am using Trip model and TripStop model. Trip model has list of trip stop models. Following is my Trip model:</p>
  
  <pre><code>@Entity
  @Table(name = "Trip")
  public class TripModel {
      @Id
      @Column(name = "tripid")
      @GeneratedValue
      private int tripId;
  
      @Column(name = "tripname")
      private String tripName;
  
      @Column(name = "tripdesc")
      private String tripDesc;
  
      @Column(name = "createdate")
      private Date createDate;
  
      @OneToMany(mappedBy = "tripModel", fetch = FetchType.EAGER)
      @Fetch(value = FetchMode.SUBSELECT)
      private List&lt;TripStopModel&gt; tripStopList;
  }
  </code></pre>
  
  <p>Following is my trip stop model:</p>
  
  <pre><code>@Entity
  @Table(name="TripStop")
  public class TripStopModel {
      @Id
      @Column(name="tripstopid")
      @GeneratedValue 
      private int tripStopId; 
  
      @Column(name="datetime")
      private String tripStopDateTime;
  
      @Column(name="createts")
      private Date tripStopCreateTime;
  
      @ManyToOne(optional=true)
      @JoinColumn(name="locationid")
      private LocationModel locationModel;
  
      public LocationModel getLocationModel() {
          return locationModel;
      }
  
      public void setLocationModel(LocationModel locationModel) {
          this.locationModel = locationModel;
      }
      @ManyToOne(optional=true)
      @JoinColumn(name="userid")
      private UserModel userModel;
  
      @ManyToOne(optional=true)
      @JoinColumn(name="tripid")
      private TripModel tripModel;
  }
  </code></pre>
  
  <p>This works fine. But when trip id is 0 in TripStop table, it shows following exception:</p>
  
  <pre><code>02:32:43,784 ERROR [stderr] (http--0.0.0.0-8080-5) org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.example.scm.model.TripModel#0]
  </code></pre>
  
  <p>Is there any option with which we can used trip id = 0 in TripStop table, without any exception? How can I allow this?</p>