HHH-18184 rescue @NamedQuery/@NamedNativeQuery.cacheMode
which I had promised to do in a comment Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
866a505bd0
commit
d1a824a701
|
@ -132,6 +132,14 @@ public @interface NamedNativeQuery {
|
|||
*/
|
||||
CacheRetrieveMode cacheRetrieveMode() default CacheRetrieveMode.USE;
|
||||
|
||||
/**
|
||||
* The cache interaction mode for this query.
|
||||
*
|
||||
* @see org.hibernate.query.SelectionQuery#setCacheMode(CacheMode)
|
||||
* @see org.hibernate.jpa.HibernateHints#HINT_CACHE_MODE
|
||||
*/
|
||||
CacheMode cacheMode() default CacheMode.NORMAL;
|
||||
|
||||
/**
|
||||
* Whether the results should be loaded in read-only mode.
|
||||
* Default is {@code false}.
|
||||
|
|
|
@ -14,7 +14,7 @@ import jakarta.persistence.CacheRetrieveMode;
|
|||
import jakarta.persistence.CacheStoreMode;
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.Remove;
|
||||
import org.hibernate.CacheMode;
|
||||
|
||||
import static java.lang.annotation.ElementType.PACKAGE;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
|
@ -126,6 +126,14 @@ public @interface NamedQuery {
|
|||
*/
|
||||
CacheRetrieveMode cacheRetrieveMode() default CacheRetrieveMode.USE;
|
||||
|
||||
/**
|
||||
* The cache interaction mode for this query.
|
||||
*
|
||||
* @see org.hibernate.query.SelectionQuery#setCacheMode(CacheMode)
|
||||
* @see org.hibernate.jpa.HibernateHints#HINT_CACHE_MODE
|
||||
*/
|
||||
CacheMode cacheMode() default CacheMode.NORMAL;
|
||||
|
||||
/**
|
||||
* Whether the results should be loaded in read-only mode.
|
||||
* Default is {@code false}.
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.lang.annotation.Annotation;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.annotations.FlushModeType;
|
||||
import org.hibernate.annotations.NamedNativeQuery;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQueryImpl;
|
||||
|
@ -76,6 +77,10 @@ public class NamedNativeQueryAnnotation implements NamedNativeQuery {
|
|||
this.comment = annotation.comment();
|
||||
this.cacheStoreMode = annotation.cacheStoreMode();
|
||||
this.cacheRetrieveMode = annotation.cacheRetrieveMode();
|
||||
if ( annotation.cacheMode() != CacheMode.NORMAL ) {
|
||||
this.cacheStoreMode = annotation.cacheMode().getJpaStoreMode();
|
||||
this.cacheRetrieveMode = annotation.cacheMode().getJpaRetrieveMode();
|
||||
}
|
||||
this.readOnly = annotation.readOnly();
|
||||
this.querySpaces = annotation.querySpaces();
|
||||
this.callable = annotation.callable();
|
||||
|
@ -214,6 +219,11 @@ public class NamedNativeQueryAnnotation implements NamedNativeQuery {
|
|||
this.cacheRetrieveMode = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheMode cacheMode() {
|
||||
return CacheMode.fromJpaModes( cacheRetrieveMode, cacheStoreMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readOnly() {
|
||||
return readOnly;
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.boot.models.annotations.internal;
|
|||
|
||||
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;
|
||||
|
@ -65,6 +66,10 @@ public class NamedQueryAnnotation implements NamedQuery {
|
|||
this.comment = annotation.comment();
|
||||
this.cacheStoreMode = annotation.cacheStoreMode();
|
||||
this.cacheRetrieveMode = annotation.cacheRetrieveMode();
|
||||
if ( annotation.cacheMode() != CacheMode.NORMAL ) {
|
||||
this.cacheStoreMode = annotation.cacheMode().getJpaStoreMode();
|
||||
this.cacheRetrieveMode = annotation.cacheMode().getJpaRetrieveMode();
|
||||
}
|
||||
this.readOnly = annotation.readOnly();
|
||||
}
|
||||
|
||||
|
@ -189,6 +194,11 @@ public class NamedQueryAnnotation implements NamedQuery {
|
|||
this.cacheRetrieveMode = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheMode cacheMode() {
|
||||
return CacheMode.fromJpaModes( cacheRetrieveMode, cacheStoreMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readOnly() {
|
||||
return readOnly;
|
||||
|
|
Loading…
Reference in New Issue