HHH-17720 - Add common JAXB contracts for named queries
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
b7bac9464a
commit
02096bd1a5
|
@ -142,7 +142,7 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToManyImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToOneImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyColumnImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedHqlQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNaturalIdImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToManyImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOneImpl;
|
||||
|
@ -927,8 +927,8 @@ public class HbmXmlTransformer {
|
|||
}
|
||||
}
|
||||
|
||||
private static JaxbNamedQueryImpl transformNamedQuery(JaxbHbmNamedQueryType hbmQuery, String name) {
|
||||
final JaxbNamedQueryImpl query = new JaxbNamedQueryImpl();
|
||||
private static JaxbNamedHqlQueryImpl transformNamedQuery(JaxbHbmNamedQueryType hbmQuery, String name) {
|
||||
final JaxbNamedHqlQueryImpl query = new JaxbNamedHqlQueryImpl();
|
||||
query.setName( name );
|
||||
query.setCacheable( hbmQuery.isCacheable() );
|
||||
query.setCacheMode( hbmQuery.getCacheMode() );
|
||||
|
|
|
@ -96,7 +96,7 @@ public interface JaxbEntity extends JaxbEntityOrMappedSuperclass {
|
|||
|
||||
@Nullable JaxbGenericIdGeneratorImpl getGenericGenerator();
|
||||
|
||||
List<JaxbNamedQueryImpl> getNamedQueries();
|
||||
List<JaxbNamedHqlQueryImpl> getNamedQueries();
|
||||
List<JaxbNamedNativeQueryImpl> getNamedNativeQueries();
|
||||
List<JaxbNamedStoredProcedureQueryImpl> getNamedStoredProcedureQueries();
|
||||
List<JaxbSqlResultSetMappingImpl> getSqlResultSetMappings();
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.jaxb.mapping.spi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
|
||||
/**
|
||||
* @author Jan Schatteman
|
||||
*/
|
||||
public interface JaxbNamedQuery extends JaxbQueryHintContainer {
|
||||
String getQuery();
|
||||
String getComment();
|
||||
Integer getTimeout();
|
||||
Boolean isCacheable();
|
||||
String getCacheRegion();
|
||||
Integer getFetchSize();
|
||||
Boolean isReadOnly();
|
||||
List<JaxbQueryParamTypeImpl> getQueryParam();
|
||||
CacheMode getCacheMode();
|
||||
FlushMode getFlushMode();
|
||||
}
|
|
@ -11,7 +11,8 @@ import java.util.List;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface JaxbNamedQueryBase {
|
||||
public interface JaxbQueryHintContainer {
|
||||
String getName();
|
||||
String getDescription();
|
||||
List<? extends JaxbQueryHint> getHints();
|
||||
}
|
|
@ -11,7 +11,7 @@ import java.lang.annotation.Annotation;
|
|||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.annotations.FlushModeType;
|
||||
import org.hibernate.annotations.NamedQuery;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedHqlQueryImpl;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||
|
@ -209,7 +209,7 @@ public class NamedQueryAnnotation implements NamedQuery {
|
|||
}
|
||||
|
||||
|
||||
public void apply(JaxbNamedQueryImpl jaxbNamedQuery, XmlDocumentContext xmlDocumentContext) {
|
||||
public void apply(JaxbNamedHqlQueryImpl jaxbNamedQuery, XmlDocumentContext xmlDocumentContext) {
|
||||
name( jaxbNamedQuery.getName() );
|
||||
query( jaxbNamedQuery.getQuery() );
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.boot.models.annotations.internal;
|
|||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedHqlQueryImpl;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.QueryProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
|
@ -117,7 +117,7 @@ public class NamedQueryJpaAnnotation implements NamedQuery {
|
|||
}
|
||||
|
||||
|
||||
public void apply(JaxbNamedQueryImpl jaxbNamedQuery, XmlDocumentContext xmlDocumentContext) {
|
||||
public void apply(JaxbNamedHqlQueryImpl jaxbNamedQuery, XmlDocumentContext xmlDocumentContext) {
|
||||
name( jaxbNamedQuery.getName() );
|
||||
query( jaxbNamedQuery.getQuery() );
|
||||
lockMode( coalesce( jaxbNamedQuery.getLockMode(), jakarta.persistence.LockModeType.NONE ) );
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbGenericIdGeneratorImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJavaTypeRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJdbcTypeRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryBase;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbQueryHintContainer;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedHqlQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedStoredProcedureQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbQueryHint;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSequenceGeneratorImpl;
|
||||
|
@ -965,7 +965,7 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
} );
|
||||
}
|
||||
|
||||
private void collectNamedQueries(List<JaxbNamedQueryImpl> jaxbNamedQueries, XmlDocumentContext xmlDocumentContext) {
|
||||
private void collectNamedQueries(List<JaxbNamedHqlQueryImpl> jaxbNamedQueries, XmlDocumentContext xmlDocumentContext) {
|
||||
if ( isEmpty( jaxbNamedQueries ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -974,7 +974,7 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
namedQueryRegistrations = new HashMap<>();
|
||||
}
|
||||
|
||||
for ( JaxbNamedQueryImpl jaxbNamedQuery : jaxbNamedQueries ) {
|
||||
for ( JaxbNamedHqlQueryImpl jaxbNamedQuery : jaxbNamedQueries ) {
|
||||
final NamedQueryJpaAnnotation queryAnnotation = JpaAnnotations.NAMED_QUERY.createUsage( xmlDocumentContext.getModelBuildingContext() );
|
||||
namedQueryRegistrations.put(
|
||||
jaxbNamedQuery.getName(),
|
||||
|
@ -995,7 +995,7 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
}
|
||||
}
|
||||
|
||||
private QueryHint[] collectQueryHints(JaxbNamedQueryImpl jaxbNamedQuery, XmlDocumentContext xmlDocumentContext) {
|
||||
private QueryHint[] collectQueryHints(JaxbNamedHqlQueryImpl jaxbNamedQuery, XmlDocumentContext xmlDocumentContext) {
|
||||
final List<QueryHint> hints = extractQueryHints( jaxbNamedQuery );
|
||||
|
||||
if ( jaxbNamedQuery.isCacheable() == Boolean.TRUE ) {
|
||||
|
@ -1183,7 +1183,7 @@ public class GlobalRegistrationsImpl implements GlobalRegistrations {
|
|||
}
|
||||
}
|
||||
|
||||
private List<QueryHint> extractQueryHints(JaxbNamedQueryBase jaxbQuery) {
|
||||
private List<QueryHint> extractQueryHints(JaxbQueryHintContainer jaxbQuery) {
|
||||
final List<QueryHint> hints = new ArrayList<>();
|
||||
for ( JaxbQueryHint jaxbHint : jaxbQuery.getHints() ) {
|
||||
final QueryHintJpaAnnotation hint = JpaAnnotations.QUERY_HINT.createUsage( sourceModelContext );
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityResultImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbFieldResultImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedHqlQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedStoredProcedureQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbQueryHint;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbQueryHintImpl;
|
||||
|
@ -80,7 +80,7 @@ public class QueryProcessing {
|
|||
List<NamedQueryJpaAnnotation> namedJpqlQueryList = null;
|
||||
|
||||
for ( int i = 0; i < jaxbEntity.getNamedQueries().size(); i++ ) {
|
||||
final JaxbNamedQueryImpl jaxbNamedQuery = jaxbEntity.getNamedQueries().get( i );
|
||||
final JaxbNamedHqlQueryImpl jaxbNamedQuery = jaxbEntity.getNamedQueries().get( i );
|
||||
|
||||
if ( CollectionHelper.isNotEmpty( jaxbNamedQuery.getHints() ) ) {
|
||||
// treat this as a Jakarta Persistence named-query
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbJavaTypeRegistrationImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJdbcTypeRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclassImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedHqlQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedStoredProcedureQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeRegistrationImpl;
|
||||
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
|
||||
|
@ -52,7 +52,7 @@ public class XmlDocumentImpl implements XmlDocument {
|
|||
private final List<JaxbCompositeUserTypeRegistrationImpl> compositeUserTypeRegistrations;
|
||||
private final List<JaxbCollectionUserTypeRegistrationImpl> collectionUserTypeRegistrations;
|
||||
private final List<JaxbEmbeddableInstantiatorRegistrationImpl> embeddableInstantiatorRegistrations;
|
||||
private final Map<String, JaxbNamedQueryImpl> jpaNamedQueries;
|
||||
private final Map<String, JaxbNamedHqlQueryImpl> jpaNamedQueries;
|
||||
private final Map<String, JaxbNamedNativeQueryImpl> jpaNamedNativeQueries;
|
||||
private final Map<String, JaxbHbmNamedQueryType> hibernateNamedQueries;
|
||||
private final Map<String, JaxbHbmNamedNativeQueryType> hibernateNamedNativeQueries;
|
||||
|
@ -71,7 +71,7 @@ public class XmlDocumentImpl implements XmlDocument {
|
|||
List<JaxbCompositeUserTypeRegistrationImpl> compositeUserTypeRegistrations,
|
||||
List<JaxbCollectionUserTypeRegistrationImpl> collectionUserTypeRegistrations,
|
||||
List<JaxbEmbeddableInstantiatorRegistrationImpl> embeddableInstantiatorRegistrations,
|
||||
Map<String, JaxbNamedQueryImpl> jpaNamedQueries,
|
||||
Map<String, JaxbNamedHqlQueryImpl> jpaNamedQueries,
|
||||
Map<String, JaxbNamedNativeQueryImpl> jpaNamedNativeQueries,
|
||||
Map<String, JaxbNamedStoredProcedureQueryImpl> namedStoredProcedureQueries,
|
||||
Map<String, JaxbHbmNamedQueryType> hibernateNamedQueries,
|
||||
|
@ -156,7 +156,7 @@ public class XmlDocumentImpl implements XmlDocument {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, JaxbNamedQueryImpl> getJpaNamedQueries() {
|
||||
public Map<String, JaxbNamedHqlQueryImpl> getJpaNamedQueries() {
|
||||
return jpaNamedQueries;
|
||||
}
|
||||
|
||||
|
@ -277,12 +277,12 @@ public class XmlDocumentImpl implements XmlDocument {
|
|||
);
|
||||
}
|
||||
|
||||
private static Map<String, JaxbNamedQueryImpl> toNamedQueryMap(List<JaxbNamedQueryImpl> namedQueries) {
|
||||
private static Map<String, JaxbNamedHqlQueryImpl> toNamedQueryMap(List<JaxbNamedHqlQueryImpl> namedQueries) {
|
||||
if ( isEmpty( namedQueries ) ) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
final Map<String, JaxbNamedQueryImpl> map = new HashMap<>();
|
||||
final Map<String, JaxbNamedHqlQueryImpl> map = new HashMap<>();
|
||||
namedQueries.forEach( (query) -> map.put( query.getName(), query ) );
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbJavaTypeRegistrationImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJdbcTypeRegistrationImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclassImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedHqlQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedStoredProcedureQueryImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeRegistrationImpl;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public interface XmlDocument {
|
|||
|
||||
List<JaxbEmbeddableInstantiatorRegistrationImpl> getEmbeddableInstantiatorRegistrations();
|
||||
|
||||
Map<String, JaxbNamedQueryImpl> getJpaNamedQueries();
|
||||
Map<String, JaxbNamedHqlQueryImpl> getJpaNamedQueries();
|
||||
|
||||
Map<String, JaxbNamedNativeQueryImpl> getJpaNamedNativeQueries();
|
||||
|
||||
|
|
|
@ -598,14 +598,15 @@
|
|||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='named-query']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryBase</inheritance:implements>
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQuery</inheritance:implements>
|
||||
<bindings node=".//xsd:element[@name='hint']">
|
||||
<property name="hints"/>
|
||||
</bindings>
|
||||
<class name="JaxbNamedHqlQueryImpl"/>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='named-native-query']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryBase</inheritance:implements>
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQuery</inheritance:implements>
|
||||
<bindings node=".//xsd:element[@name='synchronize']">
|
||||
<property name="synchronizations"/>
|
||||
</bindings>
|
||||
|
@ -615,7 +616,7 @@
|
|||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='named-stored-procedure-query']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQueryBase</inheritance:implements>
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbQueryHintContainer</inheritance:implements>
|
||||
<bindings node=".//xsd:element[@name='hint']">
|
||||
<property name="hints"/>
|
||||
</bindings>
|
||||
|
|
Loading…
Reference in New Issue