Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC With Lazy Loading
    primarykey
    data
    text
    <p><em>Correct me if this is an exact duplicate, I know this topic is discussed often but can't find a definitive answer.</em></p> <p><strong>The question:</strong> </p> <p>What is the best practical solution to handling Hibernate objects in a MVC webapp?</p> <p><strong>The details:</strong> </p> <p>I am using Hibernate and want to leverage lazy loading where possible.<br> I am working in a MVC style webapp.<br> I hate getting lazy load initialization exceptions.<br> I hate having to reattach Hibernate objects between transactions.</p> <p><strong>The options:</strong></p> <ol> <li>Eager load everything <ul> <li>Solves the lazy initialization problem but makes my queries bigger</li> </ul></li> <li>Use some 'Open Session in View' concept <ul> <li>I love the simplicity of it</li> <li>Objects still need to be reattached, and in an AJAXy setup, quite frequently</li> <li>A session is opened for EVERY request</li> </ul></li> <li>'touch' items I need before leaving the transaction <ul> <li>Seems flimsy at best.. and tedious</li> </ul></li> <li>Create different, simplified, 'detached' objects so the view never sees real Hibernate objects <ul> <li>These could be simpler than full Hibernate objects so it's not like a full eager load of the model</li> <li>I've heard this recommended in places to but just seems like more liability/code/work</li> </ul></li> <li>Open a session when ever I want to interact with Hibernate objects. <ul> <li>This can be wrapped up in a Spring Service layer pretty nicely, but seems excessive at times. Eg: I want <code>hibernateObject.getRelatedObjects()</code> but need to say something like <code>springService.getRelatedObjects(hibernateObject)</code></li> </ul></li> </ol> <p>Am I missing something?<br> Have I over-thought things?<br> Have I under-thought things? </p> <p><strong>PS:</strong> </p> <p>For a web framework I'm using ZK but <em>don't</em> really want a ZK specific answer.<br> I'm also using Spring and am cool with a Spring specific answer as it's so ubiquitous.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload