
And having the following mapping for this structure:
@Entity
@Table(name = "a")
class A {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", updatable = false, nullable = false)
private int aId;
@Column(name = "title")
private String title;
@Formula("(SELECT COUNT(*) FROM b WHERE b.a_id = aId)")
private Integer count;
}
< /code>
Моя цель состоит в том, чтобы получить подсчет всех ссылок на a от b (где помощь в запросе - это значение текущей сущности). < /p>
Но я получаю следующую ошибку: < /p>
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
java.sql.SQLException: Unknown column 'a0_.aId' in 'where clause'
Подробнее здесь: https://stackoverflow.com/questions/689 ... annotation