每当执行此查询时,我对 JPA 有疑问
@NamedQuery(name = "Usuario.getUsuarioIntento", query = "SELECT u.intentos_id FROM Usuario u WHERE u.username = :username and u.borrado = 0")
我收到此错误:
java.lang.IllegalArgumentException: NamedQuery of name: Usuario.getUsuarioIntento not found.
但是如果我执行这个查询
@NamedQuery(name = "Usuario.getUsuarioIntento", query = "SELECT u.id FROM Usuario u WHERE u.username = :username and u.borrado = 0")
工作正常,为什么?
我的桌子,乌苏里奥:
我尝试将其他列用作“superusuario”、“version_jpa”但不起作用,唯一可以正常工作的列是“id”、“borrado”和“用户名”
类乌苏里奥:
@Temporal(TemporalType.TIMESTAMP)
private Date fechaCreacion;
@Id
@GeneratedValue (strategy=GenerationType.AUTO)
private int id;
@OneToOne(cascade = CascadeType.ALL)
private Password password;
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.LAZY)
private List<Password> clavesAntiguas;
@OneToOne
private Persona persona;
private String sessionId;
private String username;
@ManyToOne(cascade = CascadeType.REFRESH)
private Rol rol;
@ManyToOne(cascade = CascadeType.REFRESH)
private Perfil perfil;
@OneToOne (cascade = CascadeType.ALL)
private IntentosBloqueo intentos;
private boolean superUsuario;
private int borrado;
private int esManager;
@OneToMany ( cascade = {CascadeType.ALL} , fetch = FetchType.LAZY)
private Collection<UsuarioSociedad> sociedades;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
@JoinTable (name="USR_UND_VIS",
joinColumns={
@JoinColumn (name="ID_USU", table="USUARIO", referencedColumnName="ID"),
},
inverseJoinColumns=
@JoinColumn (name="ID_UNI", table="UND_ORG", referencedColumnName="ID")
)
private List<UnidadOrganizativa> unidadesVisibles;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
@JoinTable (name="USR_UND_DIS",
joinColumns={
@JoinColumn (name="ID_USU", table="USUARIO", referencedColumnName="ID"),
},
inverseJoinColumns=
@JoinColumn (name="ID_UNI", table="UND_ORG", referencedColumnName="ID")
)
private List<UnidadOrganizativa> unidadesDisponibles;