Когда я выполнитьJPA не видит таблицу в БД
@NamedQuery (Name = "GroupsHasStudent.findByGroupsidGroups", запрос = "SELECT г ОТ GroupsHasStudent г ГДЕ g.groupsHasStudentPK.groupsidGroups =: groupsidGroups"),
из ГруппыHasStudent объект, результат сгенерирован правильно. Но другой NativeQuery
getEntityManager().
createNativeQuery(
"SELECT d.idDiscipline, d.name, gy.idGroupsYear, gy.year, g.idGroups "
+ "FROM Discipline d, Groupsyear gy, Groups g, GroupsHasStudent ghs "
+ "WHERE ghs.groupsHasStudentPK.groupsidGroups=2").
getResultList();
бросает за исключением
Internal Exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Table 'mydb.groupshasstudent' doesn't exist
На самом деле я не такой таблицы в БД, но правильное название * groups_has_student *, который указан в @Table:
(Моя сущность :)
@Entity
@Table(name = "groups_has_student")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "GroupsHasStudent.findAll", query = "SELECT g FROM GroupsHasStudent g"),
@NamedQuery(name = "GroupsHasStudent.findByGroupsidGroups", query = "SELECT g FROM GroupsHasStudent g WHERE g.groupsHasStudentPK.groupsidGroups = :groupsidGroups"),
@NamedQuery(name = "GroupsHasStudent.findByStudentUserslogin", query = "SELECT g FROM GroupsHasStudent g WHERE g.groupsHasStudentPK.studentUserslogin = :studentUserslogin")})
public class GroupsHasStudent implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
protected GroupsHasStudentPK groupsHasStudentPK;
public GroupsHasStudent() {
}
И даже когда я переименовать таблицу в MySQL для groupshasstudent есть еще одно исключение
Unknown column 'ghs.groupsHasStudentPK.studentUserslogin' in 'where clause'
І це сумно ..