Johan Blomgren (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjczZTEyOGI5...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16518?atlOrigin=eyJpIjoiNjczZT...
) HHH-16518 (
https://hibernate.atlassian.net/browse/HHH-16518?atlOrigin=eyJpIjoiNjczZT...
) Using alias which does not exists in the query (
https://hibernate.atlassian.net/browse/HHH-16518?atlOrigin=eyJpIjoiNjczZT...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Components: hibernate-core
Created: 26/Apr/2023 01:25 AM Environment: spring boot 3.0.5
org.postgresql:postgresql 42.5.4
postgres 12 Priority: Major Reporter: Johan Blomgren (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Hi!
It is possible that this might be fixed?
https://hibernate.atlassian.net/browse/HHH-16414
We have an issue where it seems that all of a sudden , once last week and now yesterday
again. Hibernate generates a query where it uses wrong alias, when trying to find
relations to “person“, by using “aktør“ (a kind of ident).
When we restart the application, it works again.
It generates:
*join aktoer a1_1 on a1_0*
select ... from po_sivilstand s1_0 where s1_0.fk_po_person_id in(select p1_0.id from
po_person p1_0 join aktoer a1_1 on a1_0.aktoer_id=p1_0.fk_aktoer_id where
p1_0.fk_aktoer_id=$1)
Code:
interface PersonRepository : JpaRepository<Person, Long> {
@Query(
"SELECT p FROM Person p" +
" WHERE p.aktør = :aktør"
)
fun findByAktør(aktør: Aktør): List<Person>
}
@EntityListeners(RollestyringMotDatabase::class)
@Entity(name = "Aktør")
@Table(name = "AKTOER")
data class Aktør(
@Id
@Column(name = "aktoer_id", updatable = false, length = 50)
@Pattern(regexp = VALID_REGEXP)
val aktørId: String,
) : BaseEntitet() {
...
}
@EntityListeners(RollestyringMotDatabase::class)
@Entity(name = "Person")
@Table(name = "PO_PERSON")
data class Person(
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"po_person_seq_generator")
@SequenceGenerator(name = "po_person_seq_generator", sequenceName =
"po_person_seq", allocationSize = 50)
val id: Long = 0,
@JsonIgnore
@ManyToOne(optional = false)
@JoinColumn(name = "fk_aktoer_id", nullable = false, updatable = false)
val aktør: Aktør,
@OneToMany(mappedBy = "person", cascade = [CascadeType.ALL], fetch =
FetchType.EAGER)
// Workaround før Hibernatebug
https://hibernate.atlassian.net/browse/HHH-1718
@Fetch(value = FetchMode.SUBSELECT)
var sivilstander: MutableList<GrSivilstand> = mutableListOf(),
...
) : BaseEntitet() {
...
}
(
https://hibernate.atlassian.net/browse/HHH-16518#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16518#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100223- sha1:038ca59 )