title: Failed to convert from type [java.lang.String] to type [java.lang.Long]
body: <p>This mapping should return a Set of subscribers or subscriptions. But instead, I get the error:</p>
  <blockquote>
  <p>There was an unexpected error (type=Bad Request, status=400).
  Failed to convert value of type 'java.lang.String' to required type 'org.project.notablog.domains.User'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.lang.Long] for value 'subscriptions'; nested exception is java.lang.NumberFormatException: For input string: &quot;subscriptions&quot;
  org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'org.project.notablog.domains.User'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.lang.Long] for value 'subscriptions'; nested exception is java.lang.NumberFormatException: For input string: &quot;subscriptions&quot;</p>
  </blockquote>
  <p>Controller:</p>
  <pre><code>
  @Controller
  @RequestMapping(&quot;/user&quot;)
  public class UserController {
  
  
      @GetMapping(&quot;{type}/{user}/list&quot;)
      public String userList(
              Model model,
              @PathVariable User user,
              @PathVariable String type
      ) {
          model.addAttribute(&quot;userChannel&quot;, user);
          model.addAttribute(&quot;type&quot;, type);
  
          if (&quot;subscriptions&quot;.equals(type)) {
              model.addAttribute(&quot;users&quot;, user.getSubscriptions());
          } else {
              model.addAttribute(&quot;users&quot;, user.getSubscribers());
          }
  
          return &quot;subscriptions&quot;;
      }
  
  }
  </code></pre>
  <p>Entity:</p>
  <pre><code>@Entity
  @Table(name = &quot;usr&quot;)
  public class User implements UserDetails {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      @NotBlank(message = &quot;Username cannot be empty&quot;)
      private String username;
  
      @NotBlank(message = &quot;Password cannot be empty&quot;)
      private String password;
  
      private boolean active;
  
      @Email(message = &quot;Email isn't correct&quot;)
      @NotBlank(message = &quot;Email cannot be empty&quot;)
      private String email;
      private String activationCode;
  
      @ElementCollection(targetClass = Role.class, fetch = FetchType.EAGER)
      @CollectionTable(name = &quot;user_role&quot;, joinColumns = @JoinColumn(name = &quot;user_id&quot;))
      @Enumerated(EnumType.STRING)
      private Set&lt;Role&gt; roles;
  
      @OneToMany(mappedBy = &quot;author&quot;, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
      private Set&lt;Message&gt; messages;
  
      @ManyToMany
      @JoinTable(
              name = &quot;user_subscriptions&quot;,
              joinColumns = { @JoinColumn(name = &quot;author_id&quot;) },
              inverseJoinColumns = { @JoinColumn(name = &quot;subscriber_id&quot;) }
      )
      private Set&lt;User&gt; subscribers = new HashSet&lt;&gt;();
  
      @ManyToMany
      @JoinTable(
              name = &quot;user_subscriptions&quot;,
              joinColumns = { @JoinColumn(name = &quot;subscriber_id&quot;) },
              inverseJoinColumns = { @JoinColumn(name = &quot;author_id&quot;) }
      )
      private Set&lt;User&gt; subscriptions = new HashSet&lt;&gt;();
  
  
  
      public User() {
      }
  
      public User(String username, String password, boolean active, Set&lt;Role&gt; roles) {
          this.username = username;
          this.password = password;
          this.active = active;
          this.roles = roles;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
          User user = (User) o;
          return Objects.equals(id, user.id);
      }
  
      @Override
      public int hashCode() {
  
          return Objects.hash(id);
      }
  
      public Boolean isAdmin()
      {
          return roles.contains(Role.ADMIN);
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getUsername() {
          return username;
      }
  
      @Override
      public boolean isAccountNonExpired() {
          return true;
      }
  
      @Override
      public boolean isAccountNonLocked() {
          return true;
      }
  
      @Override
      public boolean isCredentialsNonExpired() {
          return true;
      }
  
      @Override
      public boolean isEnabled() {
          return isActive();
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public boolean isActive() {
          return active;
      }
  
      public void setActive(boolean active) {
          this.active = active;
      }
  
      public Set&lt;Role&gt; getRoles() {
          return roles;
      }
  
      public void setRoles(Set&lt;Role&gt; roles) {
          this.roles = roles;
      }
  
      @Override
      public Collection&lt;? extends GrantedAuthority&gt; getAuthorities() {
          return getRoles();
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getActivationCode() {
          return activationCode;
      }
  
      public void setActivationCode(String activationCode) {
          this.activationCode = activationCode;
      }
  
      public Set&lt;Message&gt; getMessages() {
          return messages;
      }
  
      public void setMessages(Set&lt;Message&gt; messages) {
          this.messages = messages;
      }
  
      public Set&lt;User&gt; getSubscribers() {
          return subscribers;
      }
  
      public void setSubscribers(Set&lt;User&gt; subscribers) {
          this.subscribers = subscribers;
      }
  
      public Set&lt;User&gt; getSubscriptions() {
          return subscriptions;
      }
  
      public void setSubscriptions(Set&lt;User&gt; subscriptions) {
          this.subscriptions = subscriptions;
      }
  }
  
  </code></pre>
  <p>Freemarker template:</p>
  <pre><code>&lt;#import &quot;parts/common.ftlh&quot; as c&gt;
  
  &lt;@c.page&gt;
      &lt;h3&gt;${author.username}&lt;/h3&gt;
      &lt;div&gt;${type}&lt;/div&gt;
      &lt;ul class=&quot;list-group&quot;&gt;
          &lt;#list users as user&gt;
              &lt;li class=&quot;list-group-item&quot;&gt;
                  &lt;a href=&quot;/user-messages/${user.id}&quot;&gt;${user.getUsername()}&lt;/a&gt;
              &lt;/li&gt;
          &lt;/#list&gt;
      &lt;/ul&gt;
  &lt;/@c.page&gt;
  
  </code></pre>
  <p>I've already tried everything that came to my mind, but I can't figure out what the problem is.</p>