All Questions
5 questions
2
votes
2
answers
199
views
Lazy Initialization Sanity Check: Variable might not have been initialized
I'm combining existing import and export functions in order to reduce the number of times the user gets told the connection was refused in the event that the connection does get refused. The library I'...
1
vote
5
answers
4k
views
Is this an actual shortcut for a Java Lazy-Getter [closed]
The following is less a question than a request for evaluation.
So you will most likely be familiar with the following pattern of a lazy getter.
private Object obj;
public Object getObject() {
if(...
1
vote
5
answers
2k
views
Is Java lazy when passing parameters to a method?
I am using this code:
A a = aMap.contains(key) ? aMap.get(key) : createAExpensively(key);
I believe that Java is lazy so if aMap.contains(key)) then the createAExpensively() function is never called.
...
2
votes
1
answer
363
views
Initialization on demand for multiple static variables without static nested classes?
I want to have a class with multiple static variables that will only be initialized on demand.
public class Messages {
public static final String message1 = init1();
public static final ...
15
votes
3
answers
75k
views
Hibernate could not initialize proxy - no Session
My code retrieves all information related to the user:
SessionFactory sessionFactory = HibernateUtilities.configureSessionFactory();
Session session = sessionFactory.openSession();
UserDetails ud = ...