@Override public SessionFactoryImplementor getSessionFactory() { return delegate.getSessionFactory(); }
/** * Parses the textual graph representation into the specified graph. * * @param graph The target graph. This is the graph that will be populated by this process * @param graphText Textual representation of the graph * @param entityManager The EntityManager * * @throws InvalidGraphException if the textual representation is invalid. */ @SuppressWarnings("unchecked") public static <T> void parseInto( final Subgraph<T> graph, final CharSequence graphText, final EntityManager entityManager) { parseInto( (GraphImplementor<T>) graph, graphText, ( (SessionImplementor) entityManager ).getSessionFactory() ); }
/** * Parses the textual graph representation into the specified graph. * * @param graph The target graph. This is the graph that will be populated by this process * @param graphText Textual representation of the graph * @param entityManager The EntityManager * * @throws InvalidGraphException if the textual representation is invalid. */ @SuppressWarnings("unchecked") public static <T> void parseInto( final EntityGraph<T> graph, final CharSequence graphText, final EntityManager entityManager) { parseInto( (GraphImplementor<T>) graph, graphText, ( (SessionImplementor) entityManager ).getSessionFactory() ); }
/** * Parses the textual graph representation into the specified graph. * * @param graph The target graph. This is the graph that will be populated by this process * @param graphText Textual representation of the graph * @param entityManager The EntityManager * * @throws InvalidGraphException if the textual representation is invalid. */ public static <T> void parseInto( final Graph<T> graph, final CharSequence graphText, final EntityManager entityManager) { parseInto( (GraphImplementor<T>) graph, graphText, ( (SessionImplementor) entityManager ).getSessionFactory() ); }
private static <T> RootGraphImplementor<T> parse( final Class<T> rootType, final CharSequence graphText, final SessionImplementor session) { if ( graphText == null ) { return null; } final RootGraphImplementor<T> graph = session.createEntityGraph( rootType ); parseInto( (GraphImplementor<T>) graph, graphText, session.getSessionFactory() ); return graph; }
private boolean isNonIdentifierWhereConditionsRequired(String entityName, String propertyName, SessionImplementor session) { final Type propertyType = session.getSessionFactory().getMetamodel().entityPersister( entityName ).getPropertyType( propertyName ); if ( propertyType.isCollectionType() ) { final CollectionType collectionType = (CollectionType) propertyType; final Type collectionElementType = collectionType.getElementType( session.getSessionFactory() ); if ( collectionElementType instanceof ComponentType ) { // required for Embeddables return true; } else if ( collectionElementType instanceof MaterializedClobType || collectionElementType instanceof MaterializedNClobType ) { // for Map<> using @Lob annotations return collectionType instanceof MapType; } } return false; } }
/** * Get the property type of a given property in the specified entity. * * @param session the session * @param entityName the entity name * @param propertyName the property name * @return the property type of the property or {@code null} if the property name isn't found. */ private Type getPropertyType(SessionImplementor session, String entityName, String propertyName) { // rather than rely on QueryException from calling getPropertyType(), this allows a non-failure way // to determine whether to return null or lookup the value safely. final EntityPersister persister = session.getSessionFactory().getMetamodel().entityPersister( entityName ); for ( String name : persister.getPropertyNames() ) { if ( name.equals( propertyName ) ) { return persister.getPropertyType( propertyName ); } } return null; } }
final List<ImplicitParameterBinding> implicitParameterBindings = new ArrayList<>(); final SessionFactoryImplementor sessionFactory = entityManager.getSessionFactory();
CollectionType collectionType = (CollectionType) type; final SessionFactoryImplementor sessionFactory = ( (SessionImplementor) action.getSession() ) .getSessionFactory(); if ( collectionType.getElementType( sessionFactory ).isEntityType() && !sessionFactory.getMetamodel().collectionPersister( collectionType.getRole() ).isManyToMany() ) {
private void assertEnumProperty(Class<?> entityClass, Class<?> typeClass, String propertyName, EnumType expectedType) { doInJPA( this::entityManagerFactory, entityManager -> { final SessionFactoryImplementor sessionFactory = entityManager.unwrap( SessionImplementor.class ).getSessionFactory(); final EntityPersister entityPersister = sessionFactory.getMetamodel().entityPersister( entityClass ); final EnversService enversService = sessionFactory.getServiceRegistry().getService( EnversService.class ); final String entityName = entityPersister.getEntityName(); final String auditEntityName = enversService.getAuditEntitiesConfiguration().getAuditEntityName( entityName ); final EntityPersister auditedEntityPersister = sessionFactory.getMetamodel().entityPersister( auditEntityName ); final org.hibernate.type.Type propertyType = auditedEntityPersister.getPropertyType( propertyName ); assertTyping( CustomType.class, propertyType ); final UserType userType = ( (CustomType) propertyType ).getUserType(); assertTyping( typeClass, userType ); assertTyping( org.hibernate.type.EnumType.class, userType ); switch ( expectedType ) { case STRING: assertTrue( !( (org.hibernate.type.EnumType) userType ).isOrdinal() ); break; default: assertTrue( ( (org.hibernate.type.EnumType) userType ).isOrdinal() ); break; } } ); } }
@Override public SessionFactoryImplementor getSessionFactory() { return delegate.getSessionFactory(); }
@Override public SessionFactoryImplementor getSessionFactory() { return getSessionImplementor().getSessionFactory(); }
private HibernateOrmSearchManager getSearchManager() { if ( searchManager == null ) { HibernateSearchContextService contextService = delegate.getSessionFactory().getServiceRegistry() .getService( HibernateSearchContextService.class ); searchManager = contextService.getSearchManager( delegate ); } return searchManager; } }
@Override public Object run() { final Setter setter = ReflectionTools.getSetter( obj.getClass(), propertyData, versionsReader.getSessionImplementor().getSessionFactory().getServiceRegistry() ); // We only set a null value if the field is not primitive. Otherwise, we leave it intact. if ( value != null || !isPrimitive( setter, propertyData, obj.getClass() ) ) { setter.set( obj, value, null ); } return null; } };
@Override public Object run() { final Setter setter = ReflectionTools.getSetter( obj.getClass(), collectionPropertyData, versionsReader.getSessionImplementor().getSessionFactory().getServiceRegistry() ); setter.set( obj, collectionProxy, null ); return null; } };
private static <T> RootGraphImplementor<T> parse( final Class<T> rootType, final CharSequence graphText, final SessionImplementor session) { if ( graphText == null ) { return null; } final RootGraphImplementor<T> graph = session.createEntityGraph( rootType ); parseInto( (GraphImplementor<T>) graph, graphText, session.getSessionFactory() ); return graph; }
private HibernateOrmSearchManagerBuilder createSearchManagerBuilder(EntityManager entityManager) { SessionImplementor sessionImplementor = entityManager.unwrap( SessionImplementor.class ); SessionFactory expectedSessionFactory = mappingContext.getSessionFactory(); SessionFactory givenSessionFactory = sessionImplementor.getSessionFactory(); if ( !givenSessionFactory.equals( expectedSessionFactory ) ) { throw log.usingDifferentSessionFactories( expectedSessionFactory, givenSessionFactory ); } return new HibernateOrmSearchManagerImpl.HibernateOrmSearchManagerBuilderImpl( getDelegate(), mappingContext, sessionImplementor ); } }
public AuditReaderImpl(Session session, boolean closeable) { this.session = session; this.sessionImplementor = (SessionImplementor) session; this.closeable = closeable; final ServiceRegistry serviceRegistry = this.sessionImplementor.getSessionFactory().getServiceRegistry(); this.auditService = serviceRegistry.getService( AuditService.class ); firstLevelCache = new FirstLevelCache(); crossTypeRevisionChangesReader = new CrossTypeRevisionChangesReaderImpl( this ); }
public static boolean areDocIdAndEntityIdIdentical(EntityInfo entityInfo, SessionImplementor session) { SessionFactoryImplementor sessionFactoryImplementor = session.getSessionFactory(); ClassMetadata cm = sessionFactoryImplementor.getMetamodel().entityPersister( entityInfo.getType().getName() ).getClassMetadata(); String hibernateIdentifierProperty = cm.getIdentifierPropertyName(); return entityInfo.getIdName().equals( hibernateIdentifierProperty ); } }
private static TransactionManager lookupTransactionManager(SessionImplementor session) { return session .getSessionFactory() .getServiceRegistry() .getService( JtaPlatform.class ) .retrieveTransactionManager(); }