6 - SQM based on JPA type system
This commit is contained in:
parent
697aeb2f82
commit
b196374da9
|
@ -80,7 +80,7 @@ public class EntityInstantiator {
|
||||||
.getFactory()
|
.getFactory()
|
||||||
.getEntityPersister( entityName )
|
.getEntityPersister( entityName )
|
||||||
.getEntityTuplizer()
|
.getEntityTuplizer()
|
||||||
.instantiate( null, versionsReader.getSession() );
|
.instantiate( null, versionsReader.getSessionImplementor() );
|
||||||
|
|
||||||
// Putting the newly created entity instance into the first level cache, in case a one-to-one bidirectional
|
// Putting the newly created entity instance into the first level cache, in case a one-to-one bidirectional
|
||||||
// relation is present (which is eagerly loaded).
|
// relation is present (which is eagerly loaded).
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.envers.internal.reader;
|
package org.hibernate.envers.internal.reader;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ import org.hibernate.envers.AuditReader;
|
||||||
public interface AuditReaderImplementor extends AuditReader {
|
public interface AuditReaderImplementor extends AuditReader {
|
||||||
SessionImplementor getSessionImplementor();
|
SessionImplementor getSessionImplementor();
|
||||||
|
|
||||||
SessionImplementor getSession();
|
Session getSession();
|
||||||
|
|
||||||
FirstLevelCache getFirstLevelCache();
|
FirstLevelCache getFirstLevelCache();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,12 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SharedSessionContract;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
import org.hibernate.envers.RevisionType;
|
import org.hibernate.envers.RevisionType;
|
||||||
import org.hibernate.envers.internal.entities.RevisionTypeType;
|
import org.hibernate.envers.internal.entities.RevisionTypeType;
|
||||||
import org.hibernate.envers.internal.tools.MutableInteger;
|
import org.hibernate.envers.internal.tools.MutableInteger;
|
||||||
|
@ -29,12 +26,6 @@ import org.hibernate.envers.internal.tools.Triple;
|
||||||
import org.hibernate.envers.tools.Pair;
|
import org.hibernate.envers.tools.Pair;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
import org.hibernate.sql.Template;
|
import org.hibernate.sql.Template;
|
||||||
import org.hibernate.sql.ordering.antlr.ColumnMapper;
|
|
||||||
import org.hibernate.sql.ordering.antlr.ColumnReference;
|
|
||||||
import org.hibernate.sql.ordering.antlr.FormulaReference;
|
|
||||||
import org.hibernate.sql.ordering.antlr.OrderByAliasResolver;
|
|
||||||
import org.hibernate.sql.ordering.antlr.OrderByTranslation;
|
|
||||||
import org.hibernate.sql.ordering.antlr.SqlValueReference;
|
|
||||||
import org.hibernate.type.CustomType;
|
import org.hibernate.type.CustomType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,43 +243,46 @@ public class QueryBuilder {
|
||||||
StringTools.append( sb, getOrderList().iterator(), ", " );
|
StringTools.append( sb, getOrderList().iterator(), ", " );
|
||||||
}
|
}
|
||||||
else if ( !orderFragments.isEmpty() ) {
|
else if ( !orderFragments.isEmpty() ) {
|
||||||
sb.append( " order by " );
|
// todo (6.0) : How to backport HHH-12992 to use Template#translateOrderBy from master?
|
||||||
|
throw new NotYetImplementedFor6Exception( getClass() );
|
||||||
|
|
||||||
final Iterator<Pair<String, String>> fragmentIterator = orderFragments.iterator();
|
// sb.append( " order by " );
|
||||||
while( fragmentIterator.hasNext() ) {
|
//
|
||||||
final Pair<String, String> fragment = fragmentIterator.next();
|
// final Iterator<Pair<String, String>> fragmentIterator = orderFragments.iterator();
|
||||||
final OrderByTranslation orderByFragmentTranslation = Template.translateOrderBy(
|
// while( fragmentIterator.hasNext() ) {
|
||||||
fragment.getSecond(),
|
// final Pair<String, String> fragment = fragmentIterator.next();
|
||||||
new ColumnMapper() {
|
// final OrderByTranslation orderByFragmentTranslation = Template.translateOrderBy(
|
||||||
@Override
|
// fragment.getSecond(),
|
||||||
public SqlValueReference[] map(String reference) throws HibernateException {
|
// new ColumnMapper() {
|
||||||
return new SqlValueReference[ 0 ];
|
// @Override
|
||||||
}
|
// public SqlValueReference[] map(String reference) throws HibernateException {
|
||||||
},
|
// return new SqlValueReference[ 0 ];
|
||||||
sessionFactory,
|
// }
|
||||||
sessionFactory.getJdbcServices().getDialect(),
|
// },
|
||||||
sessionFactory.getSqlFunctionRegistry()
|
// sessionFactory,
|
||||||
);
|
// sessionFactory.getJdbcServices().getDialect(),
|
||||||
|
// sessionFactory.getSqlFunctionRegistry()
|
||||||
sb.append( orderByFragmentTranslation.injectAliases( new QueryOrderByAliasResolver( fragment.getFirst() ) ) );
|
// );
|
||||||
if ( fragmentIterator.hasNext() ) {
|
//
|
||||||
sb.append( ", " );
|
// sb.append( orderByFragmentTranslation.injectAliases( new QueryOrderByAliasResolver( fragment.getFirst() ) ) );
|
||||||
}
|
// if ( fragmentIterator.hasNext() ) {
|
||||||
}
|
// sb.append( ", " );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class QueryOrderByAliasResolver implements OrderByAliasResolver {
|
// private class QueryOrderByAliasResolver implements OrderByAliasResolver {
|
||||||
private String alias;
|
// private String alias;
|
||||||
public QueryOrderByAliasResolver(String alias) {
|
// public QueryOrderByAliasResolver(String alias) {
|
||||||
this.alias = alias;
|
// this.alias = alias;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String resolveTableAlias(String columnReference) {
|
// public String resolveTableAlias(String columnReference) {
|
||||||
return alias;
|
// return alias;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private List<String> getSelectAliasList() {
|
private List<String> getSelectAliasList() {
|
||||||
final List<String> aliasList = new ArrayList<>();
|
final List<String> aliasList = new ArrayList<>();
|
||||||
|
|
|
@ -69,16 +69,6 @@ public class AuditProperty<T> implements AuditProjection {
|
||||||
return new SimpleAuditExpression( alias, propertyNameGetter, value, " like " );
|
return new SimpleAuditExpression( alias, propertyNameGetter, value, " like " );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply a "like" constraint
|
|
||||||
*
|
|
||||||
* @deprecated since 5.2, use {@link #like(String, MatchMode)}.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public AuditCriterion like(String value, org.hibernate.criterion.MatchMode matchMode) {
|
|
||||||
return new SimpleAuditExpression( alias, propertyNameGetter, matchMode.toMatchString( value ), " like" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a "like" constraint
|
* Apply a "like" constraint
|
||||||
*/
|
*/
|
||||||
|
@ -93,16 +83,6 @@ public class AuditProperty<T> implements AuditProjection {
|
||||||
return new IlikeAuditExpression( alias, propertyNameGetter, value.toString() );
|
return new IlikeAuditExpression( alias, propertyNameGetter, value.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply an "ilike" constraint
|
|
||||||
*
|
|
||||||
* @deprecated since 5.2, use {@link #ilike(String, MatchMode)}.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public AuditCriterion ilike(String value, org.hibernate.criterion.MatchMode matchMode) {
|
|
||||||
return new IlikeAuditExpression( alias, propertyNameGetter, matchMode.toMatchString( value ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply on "ilike" constraint
|
* Apply on "ilike" constraint
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -303,7 +303,7 @@ public abstract class AbstractAuditQuery implements AuditQueryImplementor {
|
||||||
query.setComment( comment );
|
query.setComment( comment );
|
||||||
}
|
}
|
||||||
if ( flushMode != null ) {
|
if ( flushMode != null ) {
|
||||||
query.setFlushMode( flushMode );
|
query.setHibernateFlushMode( flushMode );
|
||||||
}
|
}
|
||||||
if ( cacheMode != null ) {
|
if ( cacheMode != null ) {
|
||||||
query.setCacheMode( cacheMode );
|
query.setCacheMode( cacheMode );
|
||||||
|
|
Loading…
Reference in New Issue