HHH-13194 : Some methods returning org.hibernate.query.Query are not defined for StatelessSession

HHH-13194 : Remove @Incubating from org.hibernate.query.Query
This commit is contained in:
Gail Badner 2019-02-05 14:30:46 -08:00
parent 5a58f50e09
commit 7a51b12cbb
6 changed files with 62 additions and 8 deletions

View File

@ -1161,9 +1161,6 @@ public interface Session extends SharedSessionContract, EntityManager, Hibernate
*/
void addEventListeners(SessionEventListener... listeners);
@Override
org.hibernate.query.Query createQuery(String queryString);
@Override
<T> org.hibernate.query.Query<T> createQuery(String queryString, Class<T> resultType);
@ -1176,8 +1173,6 @@ public interface Session extends SharedSessionContract, EntityManager, Hibernate
@Override
org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
@Override
org.hibernate.query.Query getNamedQuery(String queryName);
<T> org.hibernate.query.Query<T> createNamedQuery(String name, Class<T> resultType);

View File

@ -67,6 +67,12 @@ public interface SharedSessionContract extends QueryProducer, Serializable {
*/
Transaction getTransaction();
@Override
org.hibernate.query.Query createQuery(String queryString);
@Override
org.hibernate.query.Query getNamedQuery(String queryName);
/**
* Gets a ProcedureCall based on a named template
*

View File

@ -10,6 +10,8 @@ import java.io.Closeable;
import java.io.Serializable;
import java.sql.Connection;
import org.hibernate.query.NativeQuery;
/**
* A command-oriented API for performing bulk operations against a database.
* <p/>
@ -170,4 +172,7 @@ public interface StatelessSession extends SharedSessionContract, AutoCloseable,
*/
@Deprecated
Connection connection();
@Override
NativeQuery createSQLQuery(String queryString);
}

View File

@ -29,12 +29,10 @@ import javax.persistence.TypedQuery;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.Incubating;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.graph.Graph;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.RootGraph;
import org.hibernate.transform.ResultTransformer;
@ -69,7 +67,6 @@ import org.hibernate.type.Type;
* @author Steve Ebersole
* @author Gavin King
*/
@Incubating
@SuppressWarnings("UnusedDeclaration")
public interface Query<R> extends TypedQuery<R>, org.hibernate.Query<R>, CommonQueryContract {
/**

View File

@ -16,6 +16,8 @@
<generator class="native" />
</id>
<many-to-one name="org" lazy="false" fetch="join" />
<query name="contacts">from Contact</query>
</class>
<class name="Org">

View File

@ -16,7 +16,10 @@ import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.query.NativeQuery;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -72,6 +75,52 @@ public class StatelessSessionQueryTest extends BaseCoreFunctionalTestCase {
testData.cleanData();
}
@Test
@TestForIssue( jiraKey = "HHH-13194")
@SkipForDialect(value = AbstractHANADialect.class, comment = " HANA doesn't support tables consisting of only a single auto-generated column")
public void testDeprecatedQueryApis() {
TestData testData=new TestData();
testData.createData();
final String queryString = "from Contact c join fetch c.org join fetch c.org.country";
StatelessSession s = sessionFactory().openStatelessSession();
org.hibernate.Query query = s.createQuery( queryString );
assertEquals( 1, query.getResultList().size() );
query = s.getNamedQuery( Contact.class.getName() + ".contacts" );
assertEquals( 1, query.getResultList().size() );
org.hibernate.SQLQuery sqlQuery = s.createSQLQuery( "select id from Contact" );
assertEquals( 1, sqlQuery.getResultList().size() );
s.close();
testData.cleanData();
}
@Test
@TestForIssue( jiraKey = "HHH-13194")
@SkipForDialect(value = AbstractHANADialect.class, comment = " HANA doesn't support tables consisting of only a single auto-generated column")
public void testNewQueryApis() {
TestData testData=new TestData();
testData.createData();
final String queryString = "from Contact c join fetch c.org join fetch c.org.country";
StatelessSession s = sessionFactory().openStatelessSession();
org.hibernate.query.Query query = s.createQuery( queryString );
assertEquals( 1, query.getResultList().size() );
query = s.getNamedQuery( Contact.class.getName() + ".contacts" );
assertEquals( 1, query.getResultList().size() );
org.hibernate.query.NativeQuery sqlQuery = s.createSQLQuery( "select id from Contact" );
assertEquals( 1, sqlQuery.getResultList().size() );
s.close();
testData.cleanData();
}
private class TestData{
List list = new ArrayList();
public void createData(){