Olá. :)
Por favor, preciso de ajuda. Criei um banco de dados local para realizar o projeto. Porém, estou tendo problemas para realizar o login. Quando clico em "sign in", aparece o seguinte erro:
ERROR: column profiles0_.profiles_profile_id does not exist
Outras informações:
- a tabela que contém o adm_id e profile_id foi nomeada "tb_adm_profiles"
Model da entidade Admin (equivalente ao Usuario do curso; ela tem getters e setters, mas tirei pra poupar espaço):
@Entity
@Table(name = "tb_adm")
public class Admin implements UserDetails {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="adm_id")
private Long id;
@Column(name = "adm_name", nullable = false)
private String name;
@Column(name = "adm_email", nullable = false, unique = true)
private String email;
@Column(name = "adm_password", nullable = false)
private String admPassword;
@ManyToMany(fetch = FetchType.EAGER)
private List<Profile> profiles = new ArrayList<>();
public Admin() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAdmPassword() {
return admPassword;
}
public void setAdmPassword(String password) {
this.admPassword = password;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return this.profiles;
}
@Override
public String getUsername() {
return this.email;
}
@Override
public String getPassword() {
return this.admPassword;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
}
Model da entidade Profile (tbm tem getters e setters):
@Entity
@Table(name = "tb_profile")
public class Profile implements GrantedAuthority {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "profile_id")
private Long id;
@Column(name = "profile_name")
private String name;
@ManyToMany(mappedBy = "profiles", fetch = FetchType.EAGER)
private Set<Admin> admins;
public Profile() {
}
@Override
public String getAuthority() {
return this.name;
}
Script da join table:
CREATE TABLE tb_adm_profiles (
id SERIAL PRIMARY KEY,
id_profile INT NOT NULL,
id_adm INT NOT NULL,
FOREIGN KEY (id_profile) REFERENCES tb_profile (profile_id),
FOREIGN KEY (id_adm) REFERENCES tb_adm (adm_id)
);
Script da tb_adm:
create table tb_adm (
adm_id serial not null primary key,
adm_name varchar(100) not null,
adm_email varchar(100) not null unique,
adm_password text not null
);
Script da tb_profile:
create table tb_profile (
profile_id serial not null primary key,
profile_name varchar(100) not null
);
Abaixo, as fotos do banco:
Obrigada desde já.