title: Value too long for Column X Binary (255) in Java SpringBoot with JPA
body: <p>I'm trying to create a Game that has several sites, such as a Pyramid or a Temple. I get the same error for all the sites, so I'll just use on a as an example - Temple. What I'm trying to do is to initialize the gameboard, by creating new sites and assigning them to the game, and vice versa. Setting the game in the site classes works fine, but setting the sites in the parent "Game.java" throws following error:</p>
  
  <blockquote>
    <p>2017-04-13 17:23:10.183  WARN 5764 --- [           main]
    o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 22001, SQLState:
    22001 2017-04-13 17:23:10.183 ERROR 5764 --- [           main]
    o.h.engine.jdbc.spi.SqlExceptionHelper   : Value too long for column
    "TEMPLE BINARY(255)":
    "X'aced00057372002d63682e757a682e6966692e7365616c2e736f707261667331372e656e746974792e73697465732e54656d706c65bfa968665c9a87790200...
    (2722)"; SQL statement: update game set burial_chamber=?,
    current_player=?, market=?, name=?, obelisk=?, ownerid=?, pyramid=?,
    shipyard=?, status=?, temple=? where game_id=? [22001-191] 2017-04-13
    17:23:10.185  INFO 5764 --- [           main]
    o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of
    batch it still contained JDBC statements</p>
  </blockquote>
  
  <pre><code>import javax.persistence.*;
  import java.io.Serializable;
  import java.lang.reflect.Array;
  import java.util.ArrayList;
  import java.util.List;
  
  @Entity
  public class Temple implements Serializable {
  
      @Column
      private boolean isDockEmpty = true;
  
      @Id
      @GeneratedValue
      @Column(name = "id", updatable = false, nullable = false)
      private long id;
  
      @ElementCollection
      private List&lt;Color&gt; stones = new ArrayList&lt;Color&gt;();
  
      public List&lt;Color&gt; getStones (){
          return stones;
      }
  
      @Column (name = "name")
      private String name = "Temple";
  
      @OneToOne
      @JoinColumn (name = "game_id")
      private Game game;
  
      @OneToOne
      @JoinColumn(name = "SHIP_ID")
      private Ship ship;
  
      public long getId(){
          return id;
      }
  
      public void fillDock (){isDockEmpty = false;}
  
      public void setId(long id) {
          this.id = id;
      }
  
      /*public void setStones(List&lt;Stone&gt; stones) {
          this.stones = stones;
      }*/
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Game getGame() {
          return game;
      }
  
      public void setGame(Game game) {
          this.game = game;
      }
  
      public Ship getShip() {
          return ship;
      }
  
      public void setShip(Ship ship) {
          this.ship = ship;
      }
  }
  </code></pre>
  
  <p>This call here (game.setTemple(newTemple)), in the BoardService.java class throws the error:</p>
  
  <pre><code>   private void createAndAssignSites(Game game) {
  
          BurialChamber newBurialChamber = new BurialChamber();
          Pyramid newPyramid = new Pyramid();
          Obelisk newObelisk = new Obelisk();
          Temple newTemple = new Temple();
          Market newMarket = new Market();
  
          newBurialChamber.setGame(game);
          newPyramid.setGame(game);
          newObelisk.setGame(game);
          newTemple.setGame(game);
          newMarket.setGame(game);
  
  //        game.setBurialChamber(newBurialChamber);
  //        game.setPyramid(newPyramid);
  //        game.setObelisk(newObelisk);
          game.setTemple(newTemple);
  //        game.setMarket(newMarket);
  
          gameRepository.save(game);
  
          burialChamberRepository.save(newBurialChamber);
          pyramidRepository.save(newPyramid);
          obeliskRepository.save(newObelisk);
          templeRepository.save(newTemple);
          marketRepository.save(newMarket);
  </code></pre>
  
  <p>Here the Game.java class without getters and setters and other trivial methods:</p>
  
  <pre><code>import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.persistence.*;
  
  
  import ch.uzh.ifi.seal.soprafs17.constant.GameStatus;
  import ch.uzh.ifi.seal.soprafs17.entity.sites.*;
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import org.hibernate.annotations.LazyCollection;
  import org.hibernate.annotations.LazyCollectionOption;
  
  @Entity (name = "game")
  public class Game implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      private List&lt;User&gt; players = new ArrayList&lt;&gt;();
  
      private List&lt;Move&gt; moves = new ArrayList&lt;&gt;();
  
      public Game (){}
  
      public Game (String name, long ownerID, User player){
          this.name = name;
          this.ownerID = ownerID;
          this.status = GameStatus.PENDING;
          players.add(player);
      }
  
      private Long id;
  
      @Id
      @GeneratedValue
      @Column (name = "game_id")
      public Long getId (){
          return id;
      }
  
      @Column(nullable = false)
      private String name;
  
      @Column(nullable = false) 
      private Long ownerID;
  
      @Column 
      private GameStatus status;
  
      @Column 
      private Integer currentPlayer = 0;
  
      @OneToMany(mappedBy="game")
      public List&lt;Move&gt; getMoves(){
          return moves;
      }
  
      @JsonIgnore
      @LazyCollection(LazyCollectionOption.FALSE)
      @OneToMany (mappedBy="game",cascade = CascadeType.ALL)
      public List&lt;User&gt; getPlayers (){
          return players;
      }
  
      public void setPlayers (List&lt;User&gt; players){
          this.players = players;
      }
  
      @OneToOne
      private BurialChamber burialChamber;
  
      @OneToOne
      private Market market;
  
      @OneToOne
      private Obelisk obelisk;
  
      @OneToOne (mappedBy = "game")
      private Pyramid pyramid;
  
      @OneToOne
      private Shipyard shipyard;
  
      @OneToOne (mappedBy = "game")
      private Temple temple;
  </code></pre>
  
  <p>I don't understand what that 2722 character String is and where it is generated. And why the assignment works in one direction but not in the other...
  Hope you guys can point me to the error source.</p>
  
  <p>Thanks
  Arik</p>