Issue
I have this class:
import org.springframework.security.core.userdetails.UserDetails;
@Entity
@Table(name="t_user")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class User implements Serializable, UserDetails {
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
..
}
but I have this compilation error:
'Many To One' attribute type should not be a container
Solution
@ManyToOne
should annotate a field not a collection. For collection fields the right annotation is @OneToMany
.
So if you have
@ManyToOne
private List<Something> list;
that should be
@OneToMany
private List<Something> list;
Answered By – Panagiotis Bougioukos
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0