Bug 790649

Summary: REST Interface - Unable to update since Lazy loading was implemented
Product: [Community] PressGang CCMS Reporter: Lee Newson <lnewson>
Component: REST-APIAssignee: Matthew Casperson <mcaspers>
Status: CLOSED WORKSFORME QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.xCC: cbredesen, topic-tool-list
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-15 23:46:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Test Case none

Description Lee Newson 2012-02-15 03:59:04 UTC
Created attachment 562110 [details]
Test Case

Since Skynet was changed to use Lazy Loading updating entities that contain lazy loaded collections now fails via the REST Interface. One of the errors is:

"org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.redhat.topicindex.entity.Topic.childTopicToTopics, no session or session was closed"

I believe this error to be the cause of attempting to retrieve collections (eg in createRESTEntityFromDBEntity) after committing a transaction. Closing the transaction closes the session/proxy that the lazy loading would normally use.

I've attached a Test Case to demonstrate that creating an entity works because everything is loaded before the transaction is committed, while attempting to update an entity fails.

Comment 1 Matthew Casperson 2012-02-15 21:32:35 UTC
Fixed in 20120216-0726

The BaseRestv1.updateEntity() method now modifies the database entity and expands the returned REST entity in one transaction.