[hibernate-issues] [JIRA] (HHH-14005) Saving envers audit entry causing Lazy Initialization exception for unitialized Lazy ManyToOne relationship

Jesse McCormick (JIRA) jira at hibernate.atlassian.net
Wed May 6 14:56:04 EDT 2020


Jesse McCormick ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ac0103b8f-9e39-4a12-b6fc-45e220c6615a ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWViNzUzZDE1MzFiNGFjMGJjYmQ1NjBmNTEzZGMxZmYiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14005?atlOrigin=eyJpIjoiOWViNzUzZDE1MzFiNGFjMGJjYmQ1NjBmNTEzZGMxZmYiLCJwIjoiaiJ9 ) HHH-14005 ( https://hibernate.atlassian.net/browse/HHH-14005?atlOrigin=eyJpIjoiOWViNzUzZDE1MzFiNGFjMGJjYmQ1NjBmNTEzZGMxZmYiLCJwIjoiaiJ9 ) Saving envers audit entry causing Lazy Initialization exception for unitialized Lazy ManyToOne relationship ( https://hibernate.atlassian.net/browse/HHH-14005?atlOrigin=eyJpIjoiOWViNzUzZDE1MzFiNGFjMGJjYmQ1NjBmNTEzZGMxZmYiLCJwIjoiaiJ9 )

Issue Type: Bug Affects Versions: 5.4.11, 5.4.12, 5.4.13, 5.4.15, 5.4.14 Assignee: Chris Cranford ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aea49f1db-ef91-4d96-8f3a-a939be8d2b1c ) Components: hibernate-envers Created: 06/May/2020 11:56 AM Priority: Major Reporter: Jesse McCormick ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ac0103b8f-9e39-4a12-b6fc-45e220c6615a )

Updating a legacy Hibernate 4 to latest 5.4.15 version resulted in an odd exception when saving the audit record for a record. Turning up the debugging reveals that the actual save of the record appears to proceed correctly, and then when envers begins to save it's audit entry, the Lazy initialization exception occurs.

Save RelatedToTaskEntity cascades to save TaskEntity, which then moves onto the Owner entity where the exception occurs. I looked at HHH-13191 ( https://hibernate.atlassian.net/browse/HHH-13191 ) Closed but toggling the proxy compliance mode didn't seem to effect it. Hibernate 5.4.1 and 5.4.10 work, it appears to have broken in 5.4.11. Looking through the release notes, maybe HHH-13760 ( https://hibernate.atlassian.net/browse/HHH-13760 ) Closed is related?

RelatedToTaskEntity

> 
> 
> 
> @Audited
> @Entity
> public class RelatedToTaskEntity extends BaseDO<Integer> {
> 
> 
> 
> private static final long serialVersionUID = 60222696142150246L;
> 
> 
> 
> @javax.persistence.Column(name = "RELATED_TO_TASK_ID")
> @Id
> @Getter
> @Setter
> @SequenceGenerator(name = "RELATED_TO_TASK_ID_GENERATOR", sequenceName =
> "SQ_RELATED_TO_TASK", allocationSize = 1)
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> "RELATED_TO_TASK_ID_GENERATOR")
> private Integer relatedToTaskId;
> 
> 
> 
> @Getter
> @Setter
> @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
> @ManyToOne
> @JoinColumn(name = "TASK_CD")
> private TaskEntity task;
> 
> 

TaskEntity

> 
> 
> 
> @Table(name = "TASK")
> @Audited
> @Entity
> @Inheritance(strategy = InheritanceType.JOINED)
> @NamedQueries(
> 
> Unknown macro: { @NamedQuery(name = "getActiveTasksByShopAndCostClass",
> query = "SELECT t FROM TaskEntity t WHERE t.closedDate is null and
> t.benefitingShopCd = ?0 and t.costClassCd = ?1"), @NamedQuery(name =
> "getActiveTasksBySiteAndTeamAndCostClass", query = "SELECT t FROM
> TaskEntity t, UserInfoEntity u WHERE t.ownerId = u.userId and
> u.shop.site.siteId = ?0 and t.closedDate is null and t.team.teamId = ?1
> and t.costClassCd = ?2") }
> 
> 
> )
> public class TaskEntity extends BaseDO<Long> {
> @NotAudited
> private static final long serialVersionUID = -5071999821653470382L;
> 
> 
> 
> @Getter
> @Setter
> @Column(name = "TASK_ID")
> @Id
> @SequenceGenerator(name = "TASK_ID_GENERATOR", sequenceName = "SQ_TASK",
> allocationSize=1)
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> "TASK_ID_GENERATOR")
> private Long id;
> 
> 
> 
> @Getter
> @Setter
> @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
> @ManyToOne(fetch = FetchType.LAZY)
> @JoinColumn(name = "OWNER_CD", referencedColumnName = "USER_ID", updatable
> = false, insertable = false)
> private UserInfoEntity owner;
> 
> 

( https://hibernate.atlassian.net/browse/HHH-14005#add-comment?atlOrigin=eyJpIjoiOWViNzUzZDE1MzFiNGFjMGJjYmQ1NjBmNTEzZGMxZmYiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14005#add-comment?atlOrigin=eyJpIjoiOWViNzUzZDE1MzFiNGFjMGJjYmQ1NjBmNTEzZGMxZmYiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100126- sha1:99a90f9 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200506/e437935f/attachment.html 


More information about the hibernate-issues mailing list