xsalefter wrote: >> Pakai Hibernate, kalo belum kena LazyInitializationException, >> berarti belum benar2 pake dan ngerti konsepnya. ;p >> >> LazyInitializationException itu bukan gara2 Spring MVC. > > Ini commentnya si gavin di seam doc: (The Hibernate team is truly fed > up with copping the blame for LazyInitializationExceptions, which are > not really Hibernate's fault, but rather the fault of the extremely > limiting persistence context model supported by stateless > architectures such as the Spring framework or the traditional > stateless session facade (anti)pattern in J2EE.) > > Resolve-nya sudah saya baca di java persistence with hibernate, tapi > kadang-kadang masih suka nongol, terutama di One-To-Many relationship > dan embedded persistence class, kayak: > > String currentCity = order.getPerson().getAddress().getCity(); // .. > etc.. etc.. etc.. > > atau > > order.getOrderDetails().iterator().next(); // etc etc etc... >
Sebenarnya Bung Gavin sudah bertindak lebih jauh dari itu. Bung Gavin sudah menciptakan JavaEE Framework yang bernama JBoss Seam. Kalau pakai JSF+EJB3+Seam maka LazyInitializationException adalah masa lalu. He he he. Alternatif dari Seam juga gampang yaitu konfigurasi Fetch.EAGER di JPA.