FAQ Database Discussion Community


LazyInitializationException when serializing Collection with Jackson

java,hibernate,jackson,resteasy,lazy-initialization
I'm building an application using AngularJs and Rest services (RestEasy) where I need to display a list of products. Once the list is loaded when the user clicks on one of the products, the details and images of this product are loaded. I don't want to load the collections associated...

Lazy initialization confusion

.net,vb.net,collections,ienumerable,lazy-initialization
Scenario I'm trying to read the resources contained in a .Net managed resource file, a ResX file. I've designed this simple class that will serve me to store/struct a collection of resources: Public Class Resource Public Property Name As String Public Property Data As Object Public ReadOnly Property Type As...

Are Swift constants lazy by default?

swift,lazy-initialization
Something I still not quite understand about Swift ... let's say I want a property that instantiates a class in a base class used for several sub classes, e.g. ... let horse = Horse(); Is horse instantiated right after app/class initialisation or when the property is accessed for the first...

symfony2 event dispatcher lazy loading listener

php,symfony2,events,dispatcher,lazy-initialization
I'm creating some of my own events using Symfony Event Dispatcher, which works fine. I noticed however, that the listener I configured in symfony is not lazy loaded, it is always initialized. It is rarely used however. The config in my services.yml looks like: my.handler: class: Acme\AcmeBundle\DependencyInjection\MyHandler arguments: - @my.dependency...

LazyInitializationException in selectManyCheckbox on @ManyToMany(fetch=LAZY)

jsf,jpa,primefaces,lazy-initialization,selectmanycheckbox
What is the best way to handle multiple chackboxes when you nead to fill a JPA M:N relation ... for example I have an JPA entity Hardware and the entity Connectivity. Hardware has a set for connectivity : private Set<Connectivity> connectivities = new HashSet<Connectivity>(0); and has a setter and getter...

Should Lazy be preferred to lazy initialization in a getter?

c#,.net,lazy-initialization
From .NET 4 onwards, Lazy<T> can be used to lazily initialize objects. Intuitively, lazy initialization can also be performed in a public property's getter to provide the same functionality to the caller. I wonder if Lazy<T> offers any inherent advantage over the latter and should thus be preferred? Personally, I...

Static string variable with complex initialization in C#

c#,static-variables,lazy-initialization
I have a class with a static string variable that has a somewhat complex initialization (I can't just set it equal to a quoted string like "whatever"). I need to run a few lines of code to actually create the value. Once it gets set, its value won't change. It's...

Can Try be lazy or eager in Scala?

scala,lazy-evaluation,lazy-initialization,eager
AFAIK, Iterator.map is lazy while Vector.map is eager, basically because they are different types of monads. I would like to know if there is any chance of having a EagerTry and LazyTry that behave just like the current Try, but with the latter (LazyTry) delaying the execution of the closure...

Swift 2.0 : infer closure type error

swift,types,init,lazy-initialization
I get error Unable to infer closure type in the current context In code which was working in Swift 1.2 private lazy var _messagesVC = { return MessagesViewController(nibName:"MessagesViewController",bundle:nil)}() Whole View Controller where I get this error import UIKit class FriendsViewController: UIViewController { @IBOutlet weak var containerView: UIView! @IBOutlet weak var...

Invoking proxied DAO methods from Spring stand alone client :- could not initialize proxy - no Session

spring,hibernate,lazy-initialization
I have a third party jar in my class path which has some services and DAO's developed on top of Spring 2.0.6 and Hibernate3.2.6. I need to call some of the services and daos. Using ClassPathXmlApplicationContext I'm able to load the application context and able to access the services and...

Spring + Hibernate : LazyInitializationException

spring,hibernate,session,lazy-initialization
I am getting the LazyInitializationException when i try to retrieve information inside a POJO. User.java public class User implements java.io.Serializable { private Set groups = new HashSet(0); public Set getGroups() { return this.groups; } } UserController.java @RequestMapping(value = "/home", method = RequestMethod.GET) public ModelAndView getHome(HttpServletRequest request) throws Exception { ModelAndView...

Lock-free thread-safe lazy initialization

java,multithreading,lazy-initialization,lock-free,wait-free
To perform lock-free and wait-free lazy initialization I do the following: private AtomicReference<Foo> instance = new AtomicReference<>(null); public Foo getInstance() { Foo foo = instance.get(); if (foo == null) { foo = new Foo(); // create and initialize actual instance if (instance.compareAndSet(null, foo)) // CAS succeeded return foo; else //...

Cannot implicitly convert Lazy to Lazy

c#,interface,initialization,lazy-initialization
I am coding a MVC 5 internet application and I have a question in regards to using an interface with Lazy<T> initialization. Here is the class definition in question: public class WebAPITokenService1_0 : IWebApiTokenService Here is my code that works with out using the interface in the declaration: Declaration: Lazy<WebAPITokenService1_0>...