lazy-loading

JPA Hibernate collections not lazily loaded

时间秒杀一切 提交于 2019-11-29 12:55:22
I have a JPA setup in such a way that if I do not use lazy load, almost the entire database will be loaded. I also use serializing directly on the models so sometimes I need to initialize the proxies. I only want to use lazy load on the collections. The fact that some singular entities are fetched eagerly works just fine. But no matter how I try to setup the collections I never get a collection of proxies, I always get the fully loaded collection. This is some example code: @Entity public class Thread implements Externalizable { @OneToMany(mappedBy = "parentThread", fetch = FetchType.LAZY)

Spring, Hibernate Lazy Loading, sessionFactory, and OpenSessionInViewFilter

独自空忆成欢 提交于 2019-11-29 12:20:18
I am using Hibernate's lazy loading, and am getting sessionFactory missing exception, even after I have defined a filter in web.xml to use OpenSessionInViewFilter <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- The definition of the Root Spring Container shared by all Servlets and Filters --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF

Lazy loading - what's the best approach?

白昼怎懂夜的黑 提交于 2019-11-29 11:50:58
问题 I have seen numerous examples of lazy loading - what's your choice? Given a model class for example: public class Person { private IList<Child> _children; public IList<Child> Children { get { if (_children == null) LoadChildren(); return _children; } } } The Person class should not know anything about how it's children are loaded .... or should it? Surely it should control when properties are populated, or not? Would you have a repository that couples a Person together with its children

Stop loading of images with javascript (lazyload)?

廉价感情. 提交于 2019-11-29 10:41:02
I am trying to stop the loading of images with javascript on dom ready and then init the loading whenever i want, a so called lazy loading of images. Something like this: $(document).ready(function () { var images = $('img'); $.each(images, function() { $(this).attr('src', ''); }); }); This doesn't work (tested in ff3.5, safari 3-4). The images is getting loaded anyway, i dont get it. For example this plugin, www.appelsiini.net/projects/lazyload, is doing the exact same thing, removing the src attribute on page load. What am i missing? EDIT: I added a test page here: http://dev.bolmaster2.com

would lazy-loading img src negatively impact SEO

◇◆丶佛笑我妖孽 提交于 2019-11-29 10:34:42
I'm working on a shopping site. We display 40 images in our results. We're looking to reduce the onload time of our page, and since images block the onload event, I'm considering lazy loading them by initially setting img.src="" and then setting them after onload. Note that this is not ajax loading of html fragments. the image html along with the alt text is present. it's just the image src is deferred. Does anyone have any idea as to whether this may harm SEO or lead to a google penalty box now that they are measuring sitespeed? Images don't block anything, they are already lazy loaded. The

how to apply the load on demand (Lazy loading) concept in datalist for Images using asp.net?

一世执手 提交于 2019-11-29 08:55:37
In my asp.net application have one data list, page load event I have to bind number of image items(1000), how to apply the load on demand (What you can say Lazy loading of images) (when scrolling the page that time only bind the items like facebook new needs page) Basically I don't want page load delay due to no of images and their loading time. my code is page load event get the data and bind the datalist SqlCommand comd = new SqlCommand("usp_GetSubCategoryProducts", OBcon); comd.CommandType = CommandType.StoredProcedure; comd.Parameters.Add("@ID", SqlDbType.Int).Value = SubCategory_id;

How to persist MEF import and export information to disk

泄露秘密 提交于 2019-11-29 07:44:27
For my application as described in this question I want to use MEF to scan the available plugin assemblies and then store all the available import and export information in a serialized format (e.g. a set of strings or a memory stream). This is necessary because I need to transfer the import and export information over an AppDomain boundary without loading the plugin assemblies (essentially I want to delay load the plugins). I found some references, for instance this one or this one but none of the links gave me any idea how to: Extract all the imports and exports from an assembly Serialize

Java lazy loading of enum instances

送分小仙女□ 提交于 2019-11-29 07:38:05
If I have a bunch of enum instances in an enum type, and if I access an instance of it the first time, all of its remaining instances too are initialized at the same time. Is there any way to initialize an enum instance only when it's accessed the first time? Not without basically making it not an enum anymore. Enums are classes . The first time a class is used, it gets loaded by the JVM and all of its static initialization is done. Setting up the enum members is a static initialization, so they're all going to be initialized. You can make the instances lazy loading on use. i.e. the

Android: lazy loading in Gallery

女生的网名这么多〃 提交于 2019-11-29 07:35:11
I've reviewed some posts about lazy loading but I believe my problem is a bit different. I have a gallery (my class extends Gallery) which displays 20 rather large in size images (400-500K each). I cannot load them all to gallery since I get an OutOfMemory exception. So, I created an array of 20 Drawables and initially populated the first 9 elements (the images come from the Web) and set all the rest to null. My intention was this: on a fling to the right, fetch element no. 10 and set to null element no. 0. On another fling to the right fetch element no. 11 and set to null element no. 1 to

Paging over a lazy-loaded collection with NHibernate

别来无恙 提交于 2019-11-29 07:09:35
问题 I read this article where Ayende states NHibernate can (compared to EF 4): Collection with lazy=”extra” – Lazy extra means that NHibernate adapts to the operations that you might run on top of your collections. That means that blog.Posts.Count will not force a load of the entire collection, but rather would create a “select count(*) from Posts where BlogId = 1” statement, and that blog.Posts.Contains() will likewise result in a single query rather than paying the price of loading the entire