feat: BAC-39 Authentication (#114)
Reviewed-on: #114 Co-authored-by: Janis <janis.e.20@gmx.de> Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
22
knockoutwhistweb/app/di/EntityManagerProvider.scala
Normal file
22
knockoutwhistweb/app/di/EntityManagerProvider.scala
Normal file
@@ -0,0 +1,22 @@
|
||||
package di
|
||||
|
||||
import com.google.inject.Provider
|
||||
import com.google.inject.Inject
|
||||
import jakarta.inject.Singleton
|
||||
import jakarta.persistence.{EntityManager, EntityManagerFactory, Persistence}
|
||||
|
||||
@Singleton
|
||||
class EntityManagerProvider @Inject()() extends Provider[EntityManager] {
|
||||
|
||||
private val emf: EntityManagerFactory = Persistence.createEntityManagerFactory("defaultPersistenceUnit")
|
||||
|
||||
override def get(): EntityManager = {
|
||||
emf.createEntityManager()
|
||||
}
|
||||
|
||||
def close(): Unit = {
|
||||
if (emf.isOpen) {
|
||||
emf.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user