Class BibernateContextHolder

java.lang.Object
io.github.blyznytsiaorg.bibernate.session.BibernateContextHolder

public class BibernateContextHolder extends Object
Internal usage for repositories etc. Utility class for managing thread-local instances of the Reflections library, which is used for classpath scanning and metadata retrieval.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • reflectionsThreadLocal

      private static final ThreadLocal<org.reflections.Reflections> reflectionsThreadLocal
      Thread-local instance of Reflections for classpath scanning and metadata retrieval.
    • entityMetadataContextHolder

      private static final ThreadLocal<Map<Class<?>,EntityMetadata>> entityMetadataContextHolder
    • sessionContextHolder

      private static final ThreadLocal<BibernateSession> sessionContextHolder
    • sessionFactoryContextHolder

      private static final ThreadLocal<BibernateSessionFactory> sessionFactoryContextHolder
  • Constructor Details

    • BibernateContextHolder

      public BibernateContextHolder()
  • Method Details

    • getReflections

      public static org.reflections.Reflections getReflections()
      Gets the thread-local instance of Reflections.
      Returns:
      The Reflections instance for the current thread.
    • setReflection

      public static void setReflection(String internalPackage)
      Sets the thread-local instance of Reflections based on the provided internal package for classpath scanning.
      Parameters:
      internalPackage - The internal package to use for classpath scanning.
    • getBibernateEntityMetadata

      public static Map<Class<?>,EntityMetadata> getBibernateEntityMetadata()
      Retrieves the entity metadata stored in the current thread's context.
      Returns:
      the map containing entity metadata, where the keys are entity classes and the values are corresponding metadata
    • setBibernateEntityMetadata

      public static void setBibernateEntityMetadata(Map<Class<?>,EntityMetadata> entityMetadata)
      Sets the entity metadata in the current thread's context.
      Parameters:
      entityMetadata - the map containing entity metadata, where the keys are entity classes and the values are corresponding metadata
    • getBibernateSession

      public static BibernateSession getBibernateSession()
    • setBibernateSession

      public static void setBibernateSession(BibernateSession bibernateSession)
    • resetBibernateSession

      public static void resetBibernateSession()
    • getBibernateSessionFactory

      public static BibernateSessionFactory getBibernateSessionFactory()
    • setBibernateSessionFactory

      public static void setBibernateSessionFactory(BibernateSessionFactory bibernateSessionFactory)
    • resetBibernateSessionFactory

      public static void resetBibernateSessionFactory()