BrightSide Workbench Full Report + Source Code
org.turro.jpa.DaoFactory Class Reference
Inheritance diagram for org.turro.jpa.DaoFactory:
Collaboration diagram for org.turro.jpa.DaoFactory:

Public Member Functions

EntityManager createEntityManager (String pu, String conf)
 
synchronized EntityManager createCachedEntityManager (String pu, String conf)
 
EntityManagerFactory getEmf ()
 
void close ()
 
void closeElephant ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 43 of file DaoFactory.java.

Member Function Documentation

◆ close()

void org.turro.jpa.DaoFactory.close ( )

Definition at line 145 of file DaoFactory.java.

145  {
146  if(emf != null) emf.close();
147  }
Here is the caller graph for this function:

◆ closeElephant()

void org.turro.jpa.DaoFactory.closeElephant ( )

Implements org.turro.action.IElephantCloseable.

Definition at line 150 of file DaoFactory.java.

150  {
151  close();
152  cachedEMs.values().forEach((em) -> {
153  em.close();
154  });
155  }
Here is the call graph for this function:

◆ createCachedEntityManager()

synchronized EntityManager org.turro.jpa.DaoFactory.createCachedEntityManager ( String  pu,
String  conf 
)

Definition at line 64 of file DaoFactory.java.

64  {
65  EntityManager cachedEM = cachedEMs.get(pu);
66  Long lastAccess = lastAccessEMs.get(pu);
67  Long time = new Date().getTime();
68  if(lastAccess == null) lastAccess = time;
69  EntityManagerFactory factory = getFactory(pu, conf);
70  if(factory != null) {
71  if(cachedEM == null || !(cachedEM.isOpen())) {
72  cachedEM = factory.createEntityManager();
73  } else if(time > lastAccess + CLEAR_CACHE) {
74  cachedEM.clear();
75  } else if(time > lastAccess + CLOSE_CACHE) {
76  try {
77  cachedEM.close();
78  } finally {
79  cachedEM = factory.createEntityManager();
80  }
81  }
82  lastAccessEMs.put(pu, time);
83  cachedEMs.put(pu, cachedEM);
84  return cachedEM;
85  }
86  return null;
87  }
Here is the caller graph for this function:

◆ createEntityManager()

EntityManager org.turro.jpa.DaoFactory.createEntityManager ( String  pu,
String  conf 
)

Definition at line 54 of file DaoFactory.java.

54  {
55  EntityManagerFactory factory = getFactory(pu, conf);
56  if(factory != null) {
57  return factory.createEntityManager();
58  }
59  return null;
60  }
Here is the caller graph for this function:

◆ getEmf()

EntityManagerFactory org.turro.jpa.DaoFactory.getEmf ( )

Definition at line 89 of file DaoFactory.java.

89  {
90  return emf;
91  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: