title: why I can't use string as id
body: <p>I am trying to create a user model with a CrudRepository:</p>
  
  <pre><code>    @Entity
      public class User {
          @Id
          @GeneratedValue
          private String username;
          private String password;
  
          public String getPassword() {
              return password;
          }
  
          public void setPassword(String password) {
              this.password = password;
          }
  
          public String getUsername() {
              return username;
          }
  
          public void setUsername(String username) {
              this.username = username;
          }
      }
  
      public interface UserRepository extends CrudRepository&lt;User, String&gt; {
  
      }
  </code></pre>
  
  <p>However I got an 500 error every time I call findOne():</p>
  
  <pre><code>@Controller
  public class UserController {
      @Autowired
      private UserRepository users;
  
      @Override
      @RequestMapping(value="/register", method=RequestMethod.POST)
      public @ResponseBody User register(@RequestBody User userToRegister) {
          String username = userToRegister.getUsername();
          User user = users.findOne(id);
          if (user != null) {
              return null;
          }
          User registeredUser = users.save(userToRegister);
          return registeredUser;
      }
  }
  </code></pre>
  
  <p>However if I just switch to an long type id instead of username itself then everything works. I think it's common to use string as id. So how to make this work?</p>
  
  <p>I use the embedded hsql database. I didn't wrote any sql code.</p>