lazy-initialization Questions
2
I have a customer and a customer info entity in my spring boot project. They have an one to many relationship.
@Data
@Builder
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "cust...
Asylum asked 10/5, 2022 at 5:43
6
Solved
So I use kotlin for android, and when inflating views, I tend to do the following:
private val recyclerView by lazy { find<RecyclerView>(R.id.recyclerView) }
This method will work. However...
Overtop asked 2/3, 2016 at 16:15
14
Solved
What are some recommended approaches to achieving thread-safe lazy initialization? For instance,
// Not thread-safe
public Foo getInstance(){
if(INSTANCE == null){
INSTANCE = new Foo();
}
ret...
Vive asked 28/11, 2011 at 14:57
15
Solved
I would like to implement lazy field initialization (or deferred initialization) without an if statement and taking advantage of lambdas. So, I would like to have the same behavior of the following...
Condescend asked 18/3, 2015 at 21:18
3
I'm using JPA2.1 and hibernate 4.3.8 and i have configured the presistence.xml to allow lazy loading
i have added
<property name="hibernate.enable_lazy_load_no_trans" value="true" />
int...
Telepathist asked 30/1, 2015 at 23:14
2
Solved
Recently I've started using the lazy initialization feature in spring a lot. And so I've been wandering - are there any actual downsides to initializing your beans lazily? If not - why is not lazy ...
Unaccountable asked 23/3, 2016 at 14:58
4
Solved
I'm being given a collection of Lazy<T> items. I then want to forcibly 'create' them all in one go.
void Test(IEnumerable<Lazy<MailMessage>> items){
}
Normally with a Lazy<T&g...
Epimenides asked 4/10, 2013 at 10:17
9
Solved
I am trying to use the generic Lazy class to instantiate a costly class with .net core dependency injection extension. I have registered the IRepo type, but I'm not sure what the registration of th...
Bichromate asked 5/7, 2017 at 19:29
2
Working on spark, sometimes I need to send a non-serializable object in each task.
A common pattern is @transient lazy val, e.g
class A(val a: Int)
def compute(rdd: RDD[Int]) = {
// lazy val in...
Jezreel asked 13/1, 2016 at 14:27
3
Solved
Seems like I'm having a problem with something that shouldn't be the case... But I would like to ask for some help.
There are some explanations here on the Stack I don't get.
Having two simple clas...
Zanthoxylum asked 21/4, 2017 at 19:43
7
I know to use lazily load objects/collections outside the session, we do Hibernate.initialize(Object obj) so that object that is passed as an argument to initialize() method is initialized and can ...
Mortensen asked 26/6, 2013 at 11:3
6
Solved
I am going through Java Memory Model video presentation and author is saying it is better to use Static Lazy Initialization compared to Lazy Initialization and I do not clear understand what he wan...
Hexameter asked 14/9, 2011 at 17:33
6
Solved
Below are two ways to implement a singleton. What are the advantages and disadvantages of each?
Static initialization:
class Singleton {
private Singleton instance;
static {
instance = new Sin...
Gothicize asked 19/3, 2014 at 5:58
4
Solved
I'm using Spring 3.1.1.RELEASE and Hibernate 4.1.0.Final. I'm getting a "could not initialize proxy - no Session" exception, despite the fact I'm wrapping the relevant method call in a @Transaction...
Toboggan asked 19/4, 2013 at 16:21
3
Solved
I've worked extensively with loading and instantiating Angular modules. (without the router)
But now with Angular 13 I'm seeing deprecations for the usual compiler tools to instantiate an NgModule:...
Kele asked 2/12, 2021 at 18:33
3
Solved
While using lazy initialisers, is there a chance of having retain cycles?
In a blog post and many other places [unowned self] is seen
class Person {
var name: String
lazy var personalizedGree...
Boltonia asked 1/7, 2016 at 9:2
6
I'm trying to fetch Entity1 by querying on mapped entities to it. I'm using CriteriaBuilder to perform this as shown below
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
Cri...
Tomsk asked 30/10, 2018 at 4:53
2
Solved
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 t...
Raver asked 6/3, 2015 at 15:14
4
Solved
In TypeScript, is there a syntax for declaring a field as lazily-initialized?
Like there is in Scala, for example:
lazy val f1 = new Family("Stevens")
Meaning that the field initializer would o...
Pipsqueak asked 16/3, 2017 at 21:59
1
Solved
Dart, Kotlin and Swift have a lazy initialization keyword that lets you avoid the usage of Optional type mainly for maintainability reason.
// Using null safety:
class Coffee {
late String _temper...
Underdrawers asked 28/3, 2021 at 15:24
3
Solved
I am using spring and hibernate.
When fetching without having implemented equals and hashCode, everyting works fine. When I add the two methods and execute the query a Lazyinitializationexception i...
Motion asked 29/11, 2020 at 9:35
2
I am working on my first Spring Boot application and I have the following problem.
I want to set the that for default all beans are lazy loaded. I know that I can add the @Lazy to all my @Componen...
Benbena asked 27/10, 2016 at 8:20
3
Solved
Haskell has a really swell undefined value, which lazily raises an exception (upon evaluation). Ocaml is of course strict, so as far as I can tell there is no equivalent of Haskell's undefined. Thi...
Heave asked 16/1, 2018 at 11:27
2
Solved
I saw answers like these, tried to clarify via comments, and was unsatisfied by examples here.
Maybe it's time for this specific question...
Why enum singleton implementation is called lazy?
public...
Faxen asked 24/9, 2020 at 17:53
1
I have a dialog fragment, and i make a class for lazy initialization. When i'm showing the dialog, it's showing like normal. but, when i'm dismissing the dialog, it crash caused by : Fragment not a...
Izaak asked 14/6, 2020 at 7:53
1 Next >
© 2022 - 2024 — McMap. All rights reserved.