Type Rapport d'exception message org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions. Collection : [Models.Gisement.listeEquipesGisement#5] description Le serveur a rencontré une erreur interne qui l'a empêché de satisfaire la requête. exception javax.persistence.PersistenceException: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions. Collection : [Models.Gisement.listeEquipesGisement#5] BLABLABLABLA
Tim Holloway wrote:Welcome to the Ranch, Fabien!
Tim Holloway wrote:
Tim Holloway wrote:That's not a true Singleton. It's not thread-safe.
For a thread-safe Singleton factory, the constructor needs to be private and the factory "get" method needs to be synchronized.
That example uses double‑checked locking; I think double‑checked locking does work, but it makes the code more complicated than it has to be. Let's have a look at Joshua Bloch's Effective Java (2/e[/i and 3/[i]e] pages 17‑18). The nearest you get to the first implementation in youir Wikipedia link is Bloch's second example. Bloch also points out that the simplest way to create a Singleton is to write a one‑element enum.
Fabien Dupuit wrote:. . . "Lazy initialization" . . . is correct ? . . .
That forgets that the INSTANCE is only instantiated when the class is loaded; if class loading isn't necessary then the INSTANCE won't be created.
Your Wikipedia link wrote:. . . lazy initialization, where the instance is created when the static method is first invoked. . . .
session/entitymanager is closed