Skip to main content

All 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'...
Trevortni's user avatar
  • 748
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(...
Lukas's user avatar
  • 364
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. ...
zli's user avatar
  • 327
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 ...
Roland's user avatar
  • 7,875
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 = ...
KyelJmD's user avatar
  • 4,722