title: Failed to convert property value of type 'java.lang.String' to required type, Column cannot be null, converter
body: <p>i'm trying to add a register in database using hibernate (OneToMany, ManyToOne) + spring mvc, i'm using a converter to convert String to object....this is my code:</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>@Entity
  @Table(name="sl_players")
  public class Player implements Serializable{
  private static final long serialVersionUID = 1L;
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name="id_player")
  private int id;
  
  @Column(name="name_player")
  private String name
  
  @ManyToOne
  @JoinColumn(name="id_team")
  private Team team;
  --------------------------------------------------------
  @Entity
  @Table(name="sl_teams")
  public class Team implements Serializable{
  
  private static final long serialVersionUID = 1L;
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name="id_team")
  private int id;
  
  @Column(name="name_team")
  private String name;
  
  @OneToMany(cascade=CascadeType.ALL)
  @JoinColumn(name="id_team")
  private List&lt;Player&gt; players = new ArrayList&lt;Player&gt;();
  </code></pre>
  
  <p><strong>CONTROLLER</strong></p>
  
  <pre><code>@Controller
  public class PlayerController {
  
  @Autowired
  private PlayerService playerService;
  @Autowired
  private TeamService teamService;
  
  @RequestMapping(value="/admin/players/save", method=RequestMethod.POST)
  public String addPlayer(@RequestParam("teamId") Integer teamId, @ModelAttribute("player") Player player, BindingResult result){
      System.out.print("Result: "+result.getAllErrors());
      if(0 == player.getId())
          this.playerService.save(player);
      else
          this.playerService.update(player,teamId);
      return "redirect:/admin/players";
  }
  @ModelAttribute("teamOptions")
  public List&lt;Team&gt; getTeam(){
      return new LinkedList&lt;Team&gt;(teamService.loadAll());
  }
  </code></pre>
  
  <p><strong>Converter</strong></p>
  
  <pre><code>@Component
  public class StringToTeam implements Converter&lt;String, Team&gt;{
  
  @Autowired
  TeamService teamService;
  
  @Override
  public Team convert(String source) {
      System.out.print("*** inside Converter ***");
      return teamService.get(Integer.parseInt(source));
  }
  </code></pre>
  
  <p><strong>servlet-context</strong></p>
  
  <pre><code>&lt;mvc:annotation-driven conversion-service="conversionService"/&gt;
  &lt;beans:bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"&gt;
      &lt;beans:property name="converters"&gt;
          &lt;beans:list&gt;
              &lt;beans:bean id="roleToUserProfile" class="com.project.converter.StringToTeam"/&gt;
          &lt;/beans:list&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>this is the output:</p>
  
  <pre><code>Result: [Field error in object 'player' on field 'team': rejected value [2]; codes [typeMismatch.player.team,typeMismatch.team,typeMismatch.com.project.model.Team,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [player.team,team]; arguments []; default message [team]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'com.project.model.Team' for property 'team'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.project.soccerleagueapp.model.Team] for property 'team': no matching editors or conversion strategy found]]
  ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Column 'id_team' cannot be null
  </code></pre>
  
  <p>Anyone can help me, please?</p>