lazy-loading

Hibernate XML Mapping: Lazy False or Fetch Select?

让人想犯罪 __ 提交于 2019-11-30 13:12:46
问题 I have a simple question. I found this Hibernate config on our project: <many-to-one name="employee" class="com.myapp.Employee" cascade="merge" lazy="false" fetch="select"> <column name="employee_id" sql-type="bigint" not-null="true"/> </many-to-one> Doesn't fetch="select" mean "Lazy load all the collections and entities" based on Fetching Strategies. But by writing lazy="false" mean do not lazy load. So the config above says: "Disable lazy loading. Enable lazy loading." In effect, this means

How to fetch a field lazily with Hibernate Criteria

陌路散爱 提交于 2019-11-30 11:22:50
Each row of the table Person (having name , firstname and age ) shall be read. EntityManager em = emf.createEntityManager(); Session s = (Session) em.getDelegate(); Criteria criteria = s.createCriteria(Person.class); criteria.setFetchMode("age", FetchMode.SELECT); But the SQL shows Hibernate: select person0_.name, person0_.firstname, person0_.age from SCOPE.PERSON person0_ How to let the age be lazy ONLY for the Criteria?? I think that lazy mode only makes sense with associations. If you are accessing a plain table it will load all the fields. If you want the age field not to appear in the SQL

Searching for a Lazy Loading jQuery Slideshow or: hacking cross-slide

北慕城南 提交于 2019-11-30 10:01:39
I am trying to get a jquery slideshow to display images from flickr, fading and scrolling. Everything works fine, except I really need Lazy Loading of the images (just loading the images on demand). I am currently using jquery.cross-slide ( http://tobia.github.com/CrossSlide/ ) but unfortunately tobia is not working on the plugin anymore and also does not want to answer to questions. I found an example of jquery.cycle, where image lazy loading is applied (see http://malsup.com/jquery/cycle/add3.html ) is there any chance of hacking this feature into the source of cross-slide or is it not

Lazy Loading recyclerView in android

两盒软妹~` 提交于 2019-11-30 09:47:19
Does anyone know how to implement Lazy Loading recyclerView in android?I'm pretty new to android and I don't know how to figure this out.I'll be thankful if anyone helps. Arslan Tazhibaev You may use EndlessRecyclerView Overview A common application feature is to load automatically more items as the user scrolls through the items (aka infinite scroll). This is done by triggering a request for more data once the user crosses a threshold of remaining items before they've hit the end. The approaches for ListView, GridView and RecyclerView (the successor to ListView) are documented here. Both are

when to use Lazy loading / Eager loading in hibernate?

半世苍凉 提交于 2019-11-30 09:26:35
I believe there is only two ways of loading objects using Hibernate and that is lazy loading and one is eager loading. Lazy loading has its own advantages, it is not loading lots of objects but only when you need them. I also have learned that if you want to force to load all the children for an object you can simply call the parent.getChildren().size() . So let's say we have the following objects @Entity public class Customer{ public Set<Order> order; } @Entity public class Order{ } let's assume we have customers who has orders in our system and it might be more than one or even null. So my

CodeIgniter Active Record: Load One Row at a Time

半腔热情 提交于 2019-11-30 09:21:57
问题 The normal result() method described in the documentation appears to load all records immediately. My application needs to load about 30,000 rows, and one at a time, submit them to a third-party search index API. Obviously loading everything into memory at once doesn't work well (errors out because of too much memory). So my question is, how can I achieve the effect of the conventional MySQLi API method, in which you load one row at a time in a loop? 回答1: Here is something you can do. while (

org.hibernate.LazyInitializationException: could not initialize proxy - no Session

一笑奈何 提交于 2019-11-30 09:11:47
I have 2 physical servers which my web application hits managed by load balancers. I always get - org.hibernate.LazyInitializationException: could not initialize proxy - no Session when one of the servers are hit while the other one runs smoothly without any problems. I have a local managed cache store enabled and managed by the application. This exception happens only while trying to access one particular column from one table. The rest of the operations work absolutely fine regardless of which server is hit. Making lazy=false will become a performance issue because the number of rows on that

When to lazy load?

天涯浪子 提交于 2019-11-30 09:06:37
I lazy load all my members. I have been doing this for a while and simply taken lazy load to be a good thing at face value. Let's say we have public class SomeClass { public int anInt; public SomeReferenceType member1; public SomeClass() { //initialize members in constructor when needed (lazy load) anInt = new int(); member1 = new SomeReferenceType(); } } Are there any disadvantages to doing things this way? Is this a proper lazy load pattern? Does it make sense to lazy load a value type (with modern RAM does it even matter)? After what I have learned from your answers, I would like to know if

Android: lazy loading in Gallery

泄露秘密 提交于 2019-11-30 08:44:15
问题 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

Lazy loading - what's the best approach?

孤街醉人 提交于 2019-11-30 08:35:21
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 collection or would you use a different approach, such as using a lazyload class - even then, I don't want a