use of org.hibernate.internal.SessionImpl in project jbpm by kiegroup.
the class DistincVsJoinPerformanceTest method copyCollectionPersisterKeys.
private void copyCollectionPersisterKeys(Attribute embeddedAttr, PluralAttribute listAttr, EntityManager em) {
String[] keys = createOriginalAndExpectedKeys(embeddedAttr, listAttr);
try {
SessionImpl session = (SessionImpl) em.getDelegate();
SessionFactoryImplementor sessionFactory = session.getSessionFactory();
CollectionPersister persister = sessionFactory.getCollectionPersister(keys[0]);
sessionFactory.getCollectionPersisters().put(keys[1], persister);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.hibernate.internal.SessionImpl in project midpoint by Evolveum.
the class HibernateToSqlTranslator method toSql.
/**
* Do not use in production code! Only for testing purposes only. Used for example during query engine upgrade.
* Method provides translation from hibernate {@link Criteria} to plain SQL string query.
*
* @param criteria
* @return SQL string, null if criteria parameter was null.
*/
public static String toSql(Criteria criteria) {
if (criteria == null) {
return null;
}
try {
CriteriaImpl c;
if (criteria instanceof CriteriaImpl) {
c = (CriteriaImpl) criteria;
} else {
CriteriaImpl.Subcriteria subcriteria = (CriteriaImpl.Subcriteria) criteria;
c = (CriteriaImpl) subcriteria.getParent();
}
SessionImpl s = (SessionImpl) c.getSession();
SessionFactoryImplementor factory = s.getSessionFactory();
String[] implementors = factory.getImplementors(c.getEntityOrClassName());
CriteriaLoader loader = new CriteriaLoader((OuterJoinLoadable) factory.getEntityPersister(implementors[0]), factory, c, implementors[0], s.getLoadQueryInfluencers());
Field f = OuterJoinLoader.class.getDeclaredField("sql");
f.setAccessible(true);
return (String) f.get(loader);
} catch (Exception ex) {
throw new SystemException(ex.getMessage(), ex);
}
}
Aggregations