MK (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjFkN2M4MmZh...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16126?atlOrigin=eyJpIjoiNjFkN2...
) HHH-16126 (
https://hibernate.atlassian.net/browse/HHH-16126?atlOrigin=eyJpIjoiNjFkN2...
) TransientObjectException when loading versioned entity from second-level cache (
https://hibernate.atlassian.net/browse/HHH-16126?atlOrigin=eyJpIjoiNjFkN2...
)
Issue Type: Bug Affects Versions: 6.2.0.CR2, 6.1.6 Assignee: Unassigned Attachments:
hibernate-test-version-transient-error.zip Components: hibernate-core Created: 01/Feb/2023
04:01 AM Priority: Blocker Reporter: MK (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
)
When using cached entities along with optimistic locking using the @Version annotation and
lazy loading a TransientObjectException may be thrown during flushing.
A test case is attached.
Entities:
@NamedQueries({
@NamedQuery(
name = "Domain.selectAll" ,
query = "SELECT DISTINCT d" +
" FROM Domain d" +
" LEFT JOIN FETCH d.servers s" )
})
@Entity
public class Domain {
@Id
@GeneratedValue
private Long id;
@ManyToOne
private Privilege privilege;
@Version
private Integer rowVersion;
@OneToMany(mappedBy = "domain" )
private Set<Server> servers;
}
@Entity
public class Privilege {
@Id
@GeneratedValue
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
private Domain domain;
@ManyToOne(fetch = FetchType.LAZY)
private Server server;
@Version
private Integer rowVersion;
}
@Entity
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Server {
@Id
@GeneratedValue
private Long id;
@ManyToOne
private Domain domain;
@ManyToOne
private Privilege privilege;
@Version
private Integer rowVersion;
}
Code:
@Test
public void hhh123Test() throws Exception {
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
// Load all domains - a TransientObjectException is thrown
List<Domain> domains =
entityManager.createNamedQuery( "Domain.selectAll" , Domain.class)
.getResultList();
entityManager.getTransaction().commit();
entityManager.close();
}
(
https://hibernate.atlassian.net/browse/HHH-16126#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16126#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#100214- sha1:06410ea )