title: Java Spring and Hibernate infinite loop on save data
body: <p>I am developing Java Spring application that has Drivers and Licenses. In MySQL database, tables Driver and License are connected Many To Many by table DRIVER_LICENSE. DRIVER_LICENSE has composite key(compound key) made from driverID and licenseID (which are integers). Also, DRIVER_LICENSE has additional fields like expiration_date and state_issued. In order to handle additional fields I have used this:</p>
  
  <p>Hibernate Many-to-Many Association with Extra Columns in Join Table Example
  <a href="http://www.codejava.net/frameworks/hibernate/hibernate-many-to-many-association-with-extra-columns-in-join-table-example" rel="nofollow">http://www.codejava.net/frameworks/hibernate/hibernate-many-to-many-association-with-extra-columns-in-join-table-example</a></p>
  
  <p>My Model layer is organized like on that example. I have braked Many To Many connection in two One To Many connections like on that example, and all works nice. Now when I save driver data there is infinite loop. My driver has List list in class Driver, that belongs to Model layer. When I
  save driver there is an infinite loop on that place.</p>
  
  <p>This is the example of that loop:
  ```</p>
  
  <pre><code>{
      "driverID":116,
      "firstName":"dd",
      "lastName":"dd",
      "middleInitials":"",
      "dateOfBirth":"Feb 9, 2016 12:00:00 AM",
      "driverLicense":[
          {"id": {
              "driver": {
                  "driverID":116,
                 "firstName":"dd",
                  "lastName":"dd",
                  "middleInitials":"",
                  "dateOfBirth":"Feb 9, 2016 12:00:00 AM",
                  "driverLicense":[
                      {"id":{
                          "driver": {
                          "driverID":116,
                          "firstName":"dd",
                          "lastName":"dd",
                          "middleInitials":"",
                          "dateOfBirth":"Feb 9, 2016 12:00:00 AM"
  </code></pre>
  
  <p>There is one more thing. When it comes to infinite loop I have a lot of GSON errors.</p>
  
  <p>Is there any solution to this problem with infinite loops? </p>