Questions tagged [lazy-initialization]

Lazy initialization is the tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed.

This is typically accomplished by maintaining a flag indicating whether the process has taken place. Each time the desired object is summoned, the flag is tested. If it is ready, it is returned. If not, it is initialized on the spot.

In case of Hibernate, the lazy initialization is made in the proxy (created in place of collection) using the hibernate session from which the object was obtained. If the collection is accessed when the original session is closed (for example, outside a @Transactional scope), the LazyInitializationException is thrown.

To initialize the collection, it is enough to call size() or iterate through all elements.

705 questions
0
votes
1 answer

Lazy Loading Binding On Mouse Hover

I am using the following binding on each cell in a large HTML Excel like grid. Right now I am binding to every cell, is there a way to do this with lazy loading it on mouse hover over a certain delay so each cell doesnt need to activate it? If the…
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
0
votes
1 answer

What's are most important functionalities of Laziness in .Net 4.0 ?

Based on MSDN, we can using lazy initialization to defer the creation of a large or resource-intensive object, or the execution of a resource-intensive task, particularly when such creation or execution might not occur during the lifetime of the…
H.Gh
  • 306
  • 2
  • 16
0
votes
1 answer

Lazy initialization of cache with Spring IBatis

We are moving our legacy implementation to Spring IBatis model. I am kind of stuck in modeling these objects in cleaner way using Spring model Lets say I have two classes [ Both of them are singleton ] DAOImpl implements DAOInterface CacheDAOImpl…
Chandra
  • 333
  • 1
  • 15
0
votes
1 answer

Should param validation be performed lazily

Following is the code for lazy intialization of an instance member. This leaves me with question of when to perform parameter validation. In the code are 2 differenct functions performing NPE check one delays it, other does not. I chose the first…
JavaDeveloper
  • 5,320
  • 16
  • 79
  • 132
0
votes
1 answer

Lazy property getting value before first get

In the beginning, there was code: public abstract class A { private string _someValue; public string SomeValue { get { if (_someValue == null) _someValue = GetValue(); return…
0
votes
1 answer

lazy instantiation UIImageView

I am trying to look at most efficient way of initialising UIIMageViews within a custom UIView class which is placed within a Custom UITableCell My custom view has more than one button. In essence I am trying replicate the standard way of setting…
user1347149
  • 67
  • 1
  • 7
0
votes
1 answer

Lazy Instantiation not working iOS

I've declared a property in the .h file called cellTitles. In my .m file, I have a method as follows: -(NSArray *)cellTitles { if(!_cellTitles){ _cellTitles = [[NSArray alloc] initWithObjects:@"several strings", nil]; …
0
votes
5 answers

Lazy python format

def check(ok, msg): if not ok: print msg check(a = 1, "a=1 expected") check(bugFile == None, "We still have a bugfile = " + bugFile) I want the latter string be evaluated only when bugFile != None. Is it reasonable?
0
votes
1 answer

Lazy Instantiation of UserControl

I have a WPF application that I am trying to switch the contents of a window efficiently. I have come up with the solution of the following: App.cs internal static Lazy HomePage; MainWindow.cs public MainWindow() { …
Daniel Underwood
  • 2,191
  • 2
  • 22
  • 48
0
votes
1 answer

Reading a text file of dictionary ? Is it a good canditate for lazy init?

I am coding a boggle solver for which I need to populate a dictionary. My approach is the do a static initialization something like: private static final Set dictionayKeys = DictionaryReader.populateDictionaryWords("/../dictionary.text); To…
JavaDeveloper
  • 5,320
  • 16
  • 79
  • 132
0
votes
0 answers

Approach to implement lazyloading with JqGrid

I have a data source with over 10,000 records. And I want to implement lazy loading with JqGrid. This is my approach: Back-end: SQL stored procedure to select data by page, page size, where expression and sort(order by) expression. Font-end: send…
Vu Nguyen
  • 3,605
  • 3
  • 22
  • 34
0
votes
1 answer

Hibernate does not bring Wrapper type fields of persistent object when using load(class, id)

I have a function that simply gets a location by id: public Location getLocationById(Long idSearchedLocation){ Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Location location = null;…
bogdan.herti
  • 1,110
  • 2
  • 9
  • 18
0
votes
2 answers

Spring batch late binding for stepExecutionContext not working

I am using Spring batch application and want to use late binding for stepExecutionContext. I am facing issues in resolving my error. Following is my reader which has sql property using late binding:
de.coding.myth
  • 125
  • 1
  • 9
0
votes
3 answers

Global instance with readonly property

I want to implement a class whose instance is global but whose property is to be initialized only once during the run time. Also the initialization is to be done as an assignment from a result of function during execution. Basically I want to do…
nishantv
  • 643
  • 4
  • 9
  • 27
0
votes
1 answer

Hibernate LazyInitializationException thrown when called through Restful web service

I'm having a weird problem. I have implemented a feature in the project i'm working on using JSPs. Now I have a new requirement where I have to implement the same feature as a REST service. I'm using the same Service and DAO methods that works…
KaR
  • 53
  • 1
  • 5