6 - SQM based on JPA type system

This commit is contained in:
Andrea Boriero 2019-07-11 18:23:39 +01:00
parent 18a52483ef
commit ffb704b532
67 changed files with 160 additions and 199 deletions

View File

@ -18,7 +18,7 @@ import javax.persistence.criteria.ParameterExpression;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
import org.hibernate.jpa.test.metamodel.Phone;

View File

@ -17,7 +17,7 @@ import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.ScrollableResults;
import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
@ -90,7 +90,7 @@ public class CriteriaToScrollableResultsFetchTest extends BaseEntityManagerFunct
int rows = scrollableResults.getRowNumber() + 1;
scrollableResults.beforeFirst();
while ( scrollableResults.next() ) {
lines.add( (OrderLine) scrollableResults.get( 0 ) );
lines.add( (OrderLine) scrollableResults.get( ) );
}
assertNotNull( lines );
assertEquals( "Expected one order line", 1, lines.size() );

View File

@ -8,7 +8,7 @@
//$Id$
package org.hibernate.test.annotations;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

View File

@ -16,10 +16,6 @@ import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import org.hibernate.Query;
import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.RequiresDialectFeature;
@ -28,12 +24,6 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* @author Vlad Mihalcea

View File

@ -12,11 +12,9 @@ import java.util.List;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -12,7 +12,7 @@ import java.util.List;
import java.util.Locale;
import org.hibernate.Filter;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.MetadataBuilder;

View File

@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.engine.spi.SessionImplementor;

View File

@ -8,7 +8,7 @@ package org.hibernate.test.annotations.derivedidentities.e1.a;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;

View File

@ -13,7 +13,7 @@ import java.util.Set;
import java.util.UUID;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.MetadataBuilder;

View File

@ -19,7 +19,7 @@ import javax.persistence.OptimisticLockException;
import org.hibernate.AnnotationException;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

View File

@ -12,7 +12,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.AbstractHANADialect;

View File

@ -8,13 +8,12 @@ package org.hibernate.test.annotations.enumerated.custom_mapkey;
import java.io.Serializable;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.hibernate.mapping.Map;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value;
import org.hibernate.query.NativeQuery;
import org.hibernate.type.EnumType;
import org.hibernate.type.Type;
@ -103,7 +102,7 @@ public class MapKeyCustomEnumTypeTest extends BaseNonConfigCoreFunctionalTestCas
assetEntityMapEnumEquals( expected, found );
//native query check
SQLQuery sqlQuery = session.createSQLQuery( nativeQueryCheck );
NativeQuery sqlQuery = session.createNativeQuery( nativeQueryCheck );
sqlQuery.setParameter( "idEntityMapEnum", expected.id );
Object o = sqlQuery.uniqueResult();
assertNotNull( o );

View File

@ -11,7 +11,7 @@ package org.hibernate.test.annotations.idclass;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -10,7 +10,7 @@ import java.util.List;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.A320;

View File

@ -11,7 +11,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.MetadataBuilder;

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.test.annotations.lob.hhh4635;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.testing.RequiresDialect;
@ -56,7 +56,7 @@ public class LobTest extends BaseCoreFunctionalTestCase {
Session session = openSession();
session.beginTransaction();
Query query = session.createSQLQuery( sql );
Query query = session.createNativeQuery( sql );
String s = (String) query.uniqueResult();
log.debug( "Using Oracle charset " + s );

View File

@ -11,7 +11,7 @@ import java.util.Collection;
import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;

View File

@ -10,7 +10,7 @@ import java.util.Iterator;
import org.hibernate.EmptyInterceptor;
import org.hibernate.MappingException;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

View File

@ -16,8 +16,7 @@ import java.util.List;
import java.util.Locale;
import org.hibernate.MappingException;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;
@ -30,6 +29,7 @@ import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.PostgresPlusDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.query.NativeQuery;
import org.hibernate.stat.Statistics;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.testing.SkipForDialect;
@ -84,9 +84,9 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
Session s = openSession();
s.beginTransaction();
s.createSQLQuery( sql ).addEntity( "t", AllTables.class ).list();
s.createSQLQuery( sql2 ).setResultSetMapping( "all" ).list();
SQLQuery q = s.createSQLQuery( sql2 );
s.createNativeQuery( sql ).addEntity( "t", AllTables.class ).list();
s.createNativeQuery( sql2 ).setResultSetMapping( "all" ).list();
NativeQuery q = s.createNativeQuery( sql2 );
q.addRoot( "t", AllTables.class ).addProperty( "tableName", "t_name" ).addProperty( "daysOld", "t_time" );
q.list();
s.getTransaction().commit();
@ -108,7 +108,7 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
);
Session s = openSession();
s.beginTransaction();
s.createSQLQuery( sql ).addEntity( "t", AllTables.class ).list();
s.createNativeQuery( sql ).addEntity( "t", AllTables.class ).list();
s.getTransaction().commit();
s.close();
}
@ -227,12 +227,12 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
s.flush();
s.clear();
List chaoses = s.createSQLQuery( "select * from CHAOS where chaos_size is null or chaos_size = :chaos_size" )
List chaoses = s.createNativeQuery( "select * from CHAOS where chaos_size is null or chaos_size = :chaos_size" )
.setParameter( "chaos_size", null )
.list();
assertEquals( 1, chaoses.size() );
chaoses = s.createSQLQuery( "select * from CHAOS where chaos_size = :chaos_size" )
chaoses = s.createNativeQuery( "select * from CHAOS where chaos_size = :chaos_size" )
.setParameter( "chaos_size", null )
.list();
// should be no results because null != null
@ -268,12 +268,12 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
s.flush();
s.clear();
List chaoses = s.createSQLQuery( "select * from CHAOS where chaos_size is null or chaos_size = :chaos_size" )
List chaoses = s.createNativeQuery( "select * from CHAOS where chaos_size is null or chaos_size = :chaos_size" )
.setParameter( "chaos_size", null, StandardBasicTypes.LONG )
.list();
assertEquals( 1, chaoses.size() );
chaoses = s.createSQLQuery( "select * from CHAOS where chaos_size = :chaos_size" )
chaoses = s.createNativeQuery( "select * from CHAOS where chaos_size = :chaos_size" )
.setParameter( "chaos_size", null, StandardBasicTypes.LONG )
.list();
// should be no results because null != null

View File

@ -9,7 +9,7 @@ package org.hibernate.test.annotations.subselect;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -12,7 +12,7 @@ import java.util.List;
import org.junit.Test;
import org.hibernate.JDBCException;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -1,11 +1,5 @@
package org.hibernate.test.bulkid;
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
import org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
/**
* @author Vlad Mihalcea
*/

View File

@ -35,7 +35,7 @@ import static org.junit.Assert.*;
import java.math.BigDecimal;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.testing.TestForIssue;

View File

@ -27,7 +27,7 @@ import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.collection.internal.PersistentMap;
import org.hibernate.testing.TestForIssue;

View File

@ -17,7 +17,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.QueryException;
import org.hibernate.Session;
@ -95,7 +95,7 @@ public class QueryLiteralTest extends BaseNonConfigCoreFunctionalTestCase {
assertEquals( "HUNDRED", entity.getSameTypeConverter() );
Session session = openSession();
String value = (String) session.createSQLQuery( "select e.same_type_converter from entity_converter e where e.id=:id" )
String value = (String) session.createNativeQuery( "select e.same_type_converter from entity_converter e where e.id=:id" )
.setParameter( "id", entity.getId() )
.uniqueResult();
assertEquals( "VALUE_HUNDRED", value );

View File

@ -9,10 +9,9 @@ package org.hibernate.test.criteria;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;

View File

@ -10,7 +10,7 @@ import java.math.BigDecimal;
import java.util.Currency;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.DB2Dialect;

View File

@ -9,7 +9,7 @@ import java.math.BigDecimal;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.MySQLDialect;

View File

@ -31,7 +31,7 @@ import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.testing.RequiresDialect;

View File

@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
import org.hibernate.LockOptions;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;

View File

@ -11,7 +11,7 @@ import java.util.HashMap;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.QueryException;
import org.hibernate.Session;
import org.hibernate.Transaction;

View File

@ -13,7 +13,7 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.Oracle9iDialect;

View File

@ -17,7 +17,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -17,7 +17,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.Oracle9iDialect;

View File

@ -17,7 +17,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -8,10 +8,8 @@ package org.hibernate.test.idprops;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;

View File

@ -10,7 +10,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.SQLServerDialect;

View File

@ -33,7 +33,7 @@ import org.hibernate.HibernateException;
import org.hibernate.LazyInitializationException;
import org.hibernate.LockMode;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.QueryException;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;

View File

@ -30,7 +30,7 @@ import org.hibernate.FlushMode;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

View File

@ -8,7 +8,7 @@ package org.hibernate.test.legacy;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;

View File

@ -14,7 +14,7 @@ import java.util.*;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

View File

@ -15,7 +15,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;

View File

@ -14,8 +14,8 @@ import java.util.Date;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.AvailableSettings;
@ -71,7 +71,7 @@ public class SQLLoaderTest extends LegacyTestCase {
Simple sim = new Simple( Long.valueOf(1) );
sim.setDate( new Date() );
session.save( sim );
Query q = session.createSQLQuery( "select {sim.*} from SimpleEntity {sim} where {sim}.date_ = ?" ).addEntity( "sim", Simple.class );
Query q = session.createNativeQuery( "select {sim.*} from SimpleEntity {sim} where {sim}.date_ = ?" ).addEntity( "sim", Simple.class );
q.setTimestamp( 0, sim.getDate() );
assertTrue ( q.list().size()==1 );
session.delete(sim);
@ -111,9 +111,9 @@ public class SQLLoaderTest extends LegacyTestCase {
session.save( b );
session.flush();
session.createSQLQuery( "select {category.*} from category {category}" ).addEntity( "category", Category.class ).list();
session.createSQLQuery( "select {simple.*} from SimpleEntity {simple}" ).addEntity( "simple", Simple.class ).list();
session.createSQLQuery( "select {a.*} from TA {a}" ).addEntity( "a", A.class ).list();
session.createNativeQuery( "select {category.*} from category {category}" ).addEntity( "category", Category.class ).list();
session.createNativeQuery( "select {simple.*} from SimpleEntity {simple}" ).addEntity( "simple", Simple.class ).list();
session.createNativeQuery( "select {a.*} from TA {a}" ).addEntity( "a", A.class ).list();
session.getTransaction().commit();
session.close();
@ -135,7 +135,7 @@ public class SQLLoaderTest extends LegacyTestCase {
s.setName( "WannaBeFound" );
session.flush();
Query query = session.createSQLQuery( "select {category.*} from category {category} where {category}.name = :name" )
Query query = session.createNativeQuery( "select {category.*} from category {category} where {category}.name = :name" )
.addEntity( "category", Category.class );
query.setProperties( s );
@ -143,24 +143,24 @@ public class SQLLoaderTest extends LegacyTestCase {
query.list();
query = session.createSQLQuery( "select {category.*} from category {category} where {category}.name in (:names)" )
query = session.createNativeQuery( "select {category.*} from category {category} where {category}.name in (:names)" )
.addEntity( "category", Category.class );
String[] str = new String[] { "WannaBeFound", "NotThere" };
query.setParameterList( "names", str );
query.uniqueResult();
query = session.createSQLQuery( "select {category.*} from category {category} where {category}.name in :names" )
query = session.createNativeQuery( "select {category.*} from category {category} where {category}.name in :names" )
.addEntity( "category", Category.class );
query.setParameterList("names", str);
query.uniqueResult();
query = session.createSQLQuery( "select {category.*} from category {category} where {category}.name in (:names)" )
query = session.createNativeQuery( "select {category.*} from category {category} where {category}.name in (:names)" )
.addEntity( "category", Category.class );
str = new String[] { "WannaBeFound" };
query.setParameterList( "names", str );
query.uniqueResult();
query = session.createSQLQuery( "select {category.*} from category {category} where {category}.name in :names" )
query = session.createNativeQuery( "select {category.*} from category {category} where {category}.name in :names" )
.addEntity( "category", Category.class );
query.setParameterList( "names", str );
query.uniqueResult();
@ -194,7 +194,7 @@ public class SQLLoaderTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
List list = s.createSQLQuery( "select {category.*} from category {category}" ).addEntity( "category", Category.class ).list();
List list = s.createNativeQuery( "select {category.*} from category {category}" ).addEntity( "category", Category.class ).list();
list.get(0);
s.getTransaction().commit();
s.close();
@ -308,7 +308,7 @@ public class SQLLoaderTest extends LegacyTestCase {
s.beginTransaction();
String sql = "select {category.*}, {assignable.*} from category {category}, \"assign-able\" {assignable}";
List list = s.createSQLQuery( sql ).addEntity( "category", Category.class ).addEntity( "assignable", Assignable.class ).list();
List list = s.createNativeQuery( sql ).addEntity( "category", Category.class ).addEntity( "assignable", Assignable.class ).list();
assertTrue(list.size() == 6); // crossproduct of 2 categories x 3 assignables
assertTrue(list.get(0) instanceof Object[]);
@ -370,19 +370,19 @@ public class SQLLoaderTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
Query basicParam = s.createSQLQuery( "select {category.*} from category {category} where {category}.name = 'Best'" )
Query basicParam = s.createNativeQuery( "select {category.*} from category {category} where {category}.name = 'Best'" )
.addEntity( "category", Category.class );
List list = basicParam.list();
assertEquals(1, list.size());
Query unnamedParam = s.createSQLQuery( "select {category.*} from category {category} where {category}.name = ? or {category}.name = ?" )
Query unnamedParam = s.createNativeQuery( "select {category.*} from category {category} where {category}.name = ? or {category}.name = ?" )
.addEntity( "category", Category.class );
unnamedParam.setString(0, "Good");
unnamedParam.setString(1, "Best");
list = unnamedParam.list();
assertEquals(2, list.size());
Query namedParam = s.createSQLQuery( "select {category.*} from category {category} where ({category}.name=:firstCat or {category}.name=:secondCat)" )
Query namedParam = s.createNativeQuery( "select {category.*} from category {category} where ({category}.name=:firstCat or {category}.name=:secondCat)" )
.addEntity( "category", Category.class);
namedParam.setString("firstCat", "Better");
namedParam.setString("secondCat", "Best");
@ -419,11 +419,11 @@ public class SQLLoaderTest extends LegacyTestCase {
if( getDialect() instanceof TimesTenDialect) {
// TimesTen does not permit general expressions (like UPPER) in the second part of a LIKE expression,
// so we execute a similar test
query = session.createSQLQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where {fn ucase(name)} like 'MAX'" )
query = session.createNativeQuery("select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where {fn ucase(name)} like 'MAX'" )
.addEntity( "a", A.class );
}
else {
query = session.createSQLQuery( "select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where {fn ucase(name)} like {fn ucase('max')}" )
query = session.createNativeQuery( "select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA where {fn ucase(name)} like {fn ucase('max')}" )
.addEntity( "a", A.class );
}
List list = query.list();
@ -465,7 +465,7 @@ public class SQLLoaderTest extends LegacyTestCase {
" b.name as {a2.name} " +
"from TA a, TA b " +
"where a.identifier_column = b.identifier_column";
Query query = session.createSQLQuery( sql ).addEntity( "a1", A.class ).addEntity( "a2", A.class );
Query query = session.createNativeQuery( sql ).addEntity( "a1", A.class ).addEntity( "a2", A.class );
List list = query.list();
assertNotNull(list);
@ -487,20 +487,20 @@ public class SQLLoaderTest extends LegacyTestCase {
session = openSession();
session.beginTransaction();
SQLQuery query = session.createSQLQuery( "select {sing.*} from Single {sing}" ).addEntity( "sing", Single.class );
NativeQuery query = session.createNativeQuery( "select {sing.*} from Single {sing}" ).addEntity( "sing", Single.class );
List list = query.list();
assertTrue(list.size()==1);
session.clear();
query = session.createSQLQuery( "select {sing.*} from Single {sing} where sing.id = ?" ).addEntity( "sing", Single.class );
query = session.createNativeQuery( "select {sing.*} from Single {sing} where sing.id = ?" ).addEntity( "sing", Single.class );
query.setString(0, "my id");
list = query.list();
assertTrue(list.size()==1);
session.clear();
query = session.createSQLQuery( "select s.id as {sing.id}, s.string_ as {sing.string}, s.prop as {sing.prop} from Single s where s.id = ?" )
query = session.createNativeQuery( "select s.id as {sing.id}, s.string_ as {sing.string}, s.prop as {sing.prop} from Single s where s.id = ?" )
.addEntity( "sing", Single.class );
query.setString(0, "my id");
list = query.list();
@ -508,7 +508,7 @@ public class SQLLoaderTest extends LegacyTestCase {
session.clear();
query = session.createSQLQuery( "select s.id as {sing.id}, s.string_ as {sing.string}, s.prop as {sing.prop} from Single s where s.id = ?" )
query = session.createNativeQuery( "select s.id as {sing.id}, s.string_ as {sing.string}, s.prop as {sing.prop} from Single s where s.id = ?" )
.addEntity( "sing", Single.class );
query.setString(0, "my id");
list = query.list();
@ -554,7 +554,7 @@ public class SQLLoaderTest extends LegacyTestCase {
Session session = openSession();
session.beginTransaction();
SQLQuery q = session.createSQLQuery( sql ).addEntity( "comp", Componentizable.class );
NativeQuery q = session.createNativeQuery( sql ).addEntity( "comp", Componentizable.class );
List list = q.list();
assertEquals( list.size(), 1 );
@ -599,7 +599,7 @@ public class SQLLoaderTest extends LegacyTestCase {
session.save(s);
session.flush();
Query query = session.createSQLQuery( "select s.category_key_col as {category.id}, s.name as {category.name}, s.\"assign-able-id\" as {category.assignable} from {category} s" )
Query query = session.createNativeQuery( "select s.category_key_col as {category.id}, s.name as {category.name}, s.\"assign-able-id\" as {category.assignable} from {category} s" )
.addEntity( "category", Category.class );
List list = query.list();
@ -628,7 +628,7 @@ public class SQLLoaderTest extends LegacyTestCase {
session = openSession();
session.beginTransaction();
Query query = session.createSQLQuery( "select s.category_key_col as {category.id}, s.name as {category.name}, s.\"assign-able-id\" as {category.assignable} from {category} s" )
Query query = session.createNativeQuery( "select s.category_key_col as {category.id}, s.name as {category.name}, s.\"assign-able-id\" as {category.assignable} from {category} s" )
.addEntity( "category", Category.class );
List list = query.list();
@ -656,7 +656,7 @@ public class SQLLoaderTest extends LegacyTestCase {
session.save(savedB);
session.flush();
Query query = session.createSQLQuery( "select identifier_column as {a.id}, clazz_discriminata as {a.class}, name as {a.name}, count_ as {a.count} from TA {a}" )
Query query = session.createNativeQuery( "select identifier_column as {a.id}, clazz_discriminata as {a.class}, name as {a.name}, count_ as {a.count} from TA {a}" )
.addEntity( "a", A.class );
List list = query.list();
@ -704,7 +704,7 @@ public class SQLLoaderTest extends LegacyTestCase {
session = openSession();
session.beginTransaction();
Query query = session.createSQLQuery( "select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA" )
Query query = session.createNativeQuery( "select identifier_column as {a.id}, clazz_discriminata as {a.class}, count_ as {a.count}, name as {a.name} from TA" )
.addEntity( "a", A.class );
List list = query.list();
@ -750,7 +750,7 @@ public class SQLLoaderTest extends LegacyTestCase {
getDialect().openQuote() + "user" + getDialect().closeQuote()
);
SQLQuery query = s.createSQLQuery( sql ).addEntity( "c", CompositeIdId.class );
NativeQuery query = s.createNativeQuery( sql ).addEntity( "c", CompositeIdId.class );
query.setString(0, "c64");
query.setString(1, "games");

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.test.legacy;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

View File

@ -9,8 +9,8 @@ package org.hibernate.test.locking.paging;
import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.testing.TestForIssue;
@ -93,7 +93,7 @@ public class PagingAndLockingTest extends BaseCoreFunctionalTestCase {
public void testNativeSql() {
Session session = openSession();
session.beginTransaction();
SQLQuery qry = session.createSQLQuery( "select * from door" );
NativeQuery qry = session.createNativeQuery( "select * from door" );
qry.addRoot( "door", Door.class );
qry.getLockOptions().setLockMode( LockMode.PESSIMISTIC_WRITE );
qry.setFirstResult( 2 );

View File

@ -12,7 +12,7 @@ import javax.persistence.Id;
import javax.persistence.Table;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.Oracle10gDialect;

View File

@ -12,10 +12,9 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
@ -186,7 +185,7 @@ public class PaginationTest extends BaseNonConfigCoreFunctionalTestCase {
assertEquals( "Description: 3", result.get( 1 ) );
assertEquals( "Description: 4", result.get( 2 ) );
result = session.createSQLQuery( "select description, xval, yval from DataPoint order by xval, yval" )
result = session.createNativeQuery( "select description, xval, yval from DataPoint order by xval, yval" )
.setFirstResult( 2 )
.setMaxResults( 5 )
.list();
@ -194,7 +193,7 @@ public class PaginationTest extends BaseNonConfigCoreFunctionalTestCase {
Object[] row = (Object[]) result.get( 0 );
assertTrue( row[0] instanceof String );
result = session.createSQLQuery( "select * from DataPoint order by xval, yval" )
result = session.createNativeQuery( "select * from DataPoint order by xval, yval" )
.setFirstResult( 2 )
.setMaxResults( 5 )
.list();
@ -216,8 +215,8 @@ public class PaginationTest extends BaseNonConfigCoreFunctionalTestCase {
.addOrder( Order.asc( "sequence" ) );
}
private SQLQuery generateBaseSQLQuery(Session session) {
return session.createSQLQuery( "select id, seqval, xval, yval, description from DataPoint order by seqval" )
private NativeQuery generateBaseSQLQuery(Session session) {
return session.createNativeQuery( "select id, seqval, xval, yval, description from DataPoint order by seqval" )
.addEntity( DataPoint.class );
}

View File

@ -17,16 +17,11 @@ import org.junit.Test;
import org.hibernate.CacheMode;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.CriteriaSpecification;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -19,13 +19,12 @@ import java.util.concurrent.Future;
import org.hibernate.EmptyInterceptor;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.SessionBuilder;
import org.hibernate.Transaction;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.criterion.Restrictions;
import org.hibernate.stat.EntityStatistics;
import org.hibernate.stat.QueryStatistics;
import org.hibernate.stat.spi.StatisticsImplementor;
@ -626,7 +625,7 @@ public class QueryCacheTest extends BaseNonConfigCoreFunctionalTestCase {
// 1 and 2+ scalars.
String sqlQuery = "select name, description from Items";
SQLQuery query = s.createSQLQuery(sqlQuery);
NativeQuery query = s.createNativeQuery( sqlQuery);
query.setCacheable(true);
query.addScalar("name");
query.addScalar("description");
@ -637,7 +636,7 @@ public class QueryCacheTest extends BaseNonConfigCoreFunctionalTestCase {
assertEquals( result1[1], "fooDescription" );
sqlQuery = "select name from Items";
query = s.createSQLQuery(sqlQuery);
query = s.createNativeQuery(sqlQuery);
query.setCacheable(true);
query.addScalar("name");
String result2 = (String) query.uniqueResult();

View File

@ -13,7 +13,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;

View File

@ -12,7 +12,7 @@ import java.util.List;
import org.hibernate.CacheMode;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
@ -99,7 +99,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
.scroll(ScrollMode.FORWARD_ONLY);
s.setDefaultReadOnly( false );
while ( sr.next() ) {
DataPoint dp = (DataPoint) sr.get(0);
DataPoint dp = (DataPoint) sr.get();
if (++i==50) {
s.setReadOnly(dp, false);
}
@ -138,7 +138,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
.setReadOnly( false )
.scroll(ScrollMode.FORWARD_ONLY);
while ( sr.next() ) {
DataPoint dp = (DataPoint) sr.get(0);
DataPoint dp = (DataPoint) sr.get();
if (++i==50) {
s.setReadOnly(dp, true);
}
@ -177,7 +177,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
.setReadOnly( true )
.scroll(ScrollMode.FORWARD_ONLY);
while ( sr.next() ) {
DataPoint dp = (DataPoint) sr.get(0);
DataPoint dp = (DataPoint) sr.get();
if (++i==50) {
s.setReadOnly(dp, false);
}
@ -217,7 +217,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
ScrollableResults sr = query.scroll(ScrollMode.FORWARD_ONLY);
s.setDefaultReadOnly( false );
while ( sr.next() ) {
DataPoint dp = (DataPoint) sr.get(0);
DataPoint dp = (DataPoint) sr.get();
if (++i==50) {
s.setReadOnly(dp, false);
}
@ -284,7 +284,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
assertFalse( s.isDefaultReadOnly() );
while ( sr.next() ) {
assertFalse( s.isDefaultReadOnly() );
dp = (DataPoint) sr.get(0);
dp = (DataPoint) sr.get();
if ( dp.getId() == dpLast.getId() ) {
//dpLast existed in the session before executing the read-only query
assertFalse( s.isReadOnly( dp ) );
@ -359,7 +359,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
assertTrue( s.isDefaultReadOnly() );
while ( sr.next() ) {
assertTrue( s.isDefaultReadOnly() );
dp = (DataPoint) sr.get(0);
dp = (DataPoint) sr.get();
if ( dp.getId() == dpLast.getId() ) {
//dpLast existed in the session before executing the read-only query
assertTrue( s.isReadOnly( dp ) );
@ -990,7 +990,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
s.setDefaultReadOnly( false );
int nExpectedChanges = 0;
while ( sr.next() ) {
dp = (DataPoint) sr.get(0);
dp = (DataPoint) sr.get();
if ( dp.getId() == dpLast.getId() ) {
//dpLast existed in the session before executing the read-only query
assertFalse( s.isReadOnly( dp ) );
@ -1041,7 +1041,7 @@ public class ReadOnlySessionTest extends AbstractReadOnlyTest {
.scroll(ScrollMode.FORWARD_ONLY);
int nExpectedChanges = 0;
while ( sr.next() ) {
dp = (DataPoint) sr.get(0);
dp = (DataPoint) sr.get();
if ( dp.getId() == dpLast.getId() ) {
//dpLast existed in the session before executing the read-only query
assertTrue( s.isReadOnly( dp ) );

View File

@ -11,7 +11,7 @@ import java.util.List;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;
@ -83,9 +83,7 @@ public class ResultTransformerTest extends BaseCoreFunctionalTestCase {
sr.first();
}
Object[] row = sr.get();
assertEquals(1, row.length);
Object obj = row[0];
Object obj = sr.get();
assertTrue(obj instanceof PartnerA);
PartnerA obj2 = (PartnerA) obj;
assertEquals("Partner A", obj2.getName());

View File

@ -13,7 +13,7 @@ import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.MetadataSources;
@ -65,7 +65,7 @@ public class SchemaUpdateWithFunctionIndexTest extends BaseNonConfigCoreFunction
private void createTable() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
Query query = session.createSQLQuery( "CREATE TABLE MyEntity(id bigint, name varchar(255));" );
Query query = session.createNativeQuery( "CREATE TABLE MyEntity(id bigint, name varchar(255));" );
query.executeUpdate();
transaction.commit();
session.close();
@ -74,7 +74,7 @@ public class SchemaUpdateWithFunctionIndexTest extends BaseNonConfigCoreFunction
private void createFunctionIndex() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
Query query = session.createSQLQuery( "CREATE UNIQUE INDEX uk_MyEntity_name_lowercase ON MyEntity (lower(name));" );
Query query = session.createNativeQuery( "CREATE UNIQUE INDEX uk_MyEntity_name_lowercase ON MyEntity (lower(name));" );
query.executeUpdate();
transaction.commit();
session.close();
@ -83,7 +83,7 @@ public class SchemaUpdateWithFunctionIndexTest extends BaseNonConfigCoreFunction
private void dropTable() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
Query query = session.createSQLQuery( "DROP TABLE IF EXISTS MyEntity;" );
Query query = session.createNativeQuery( "DROP TABLE IF EXISTS MyEntity;" );
query.executeUpdate();
transaction.commit();
session.close();
@ -92,7 +92,7 @@ public class SchemaUpdateWithFunctionIndexTest extends BaseNonConfigCoreFunction
private void dropFunctionIndex() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
Query query = session.createSQLQuery( "DROP INDEX IF EXISTS uk_MyEntity_name_lowercase;" );
Query query = session.createNativeQuery( "DROP INDEX IF EXISTS uk_MyEntity_name_lowercase;" );
query.executeUpdate();
transaction.commit();
session.close();

View File

@ -13,7 +13,7 @@ import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.MetadataSources;
@ -64,7 +64,7 @@ public class SchemaUpdateWithViewsTest extends BaseNonConfigCoreFunctionalTestCa
private void createViewWithSameNameOfEntityTable() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
Query query = session.createSQLQuery( "CREATE OR REPLACE VIEW MyEntity AS SELECT 'Hello World' " );
Query query = session.createNativeQuery( "CREATE OR REPLACE VIEW MyEntity AS SELECT 'Hello World' " );
query.executeUpdate();
transaction.commit();
session.close();
@ -84,7 +84,7 @@ public class SchemaUpdateWithViewsTest extends BaseNonConfigCoreFunctionalTestCa
private void dropView() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
Query query = session.createSQLQuery( "DROP VIEW IF EXISTS MyEntity " );
Query query = session.createNativeQuery( "DROP VIEW IF EXISTS MyEntity " );
query.executeUpdate();
transaction.commit();
session.close();

View File

@ -14,17 +14,14 @@ import java.util.List;
import org.junit.Test;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.engine.query.ParameterRecognitionException;
import org.hibernate.procedure.ProcedureCall;
import org.hibernate.test.sql.hand.Employment;
import org.hibernate.test.sql.hand.Organization;
import org.hibernate.test.sql.hand.Person;
import com.arjuna.ats.internal.jdbc.drivers.modifiers.list;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

View File

@ -18,9 +18,9 @@ import java.util.Locale;
import java.util.Map;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
import org.hibernate.QueryException;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
@ -138,7 +138,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
try {
String sql = "select {org.*} " +
"from organization org";
s.createSQLQuery( sql ).list();
s.createNativeQuery( sql ).list();
fail( "Should throw an exception since no addEntity nor addScalar has been performed." );
}
catch( PersistenceException pe) {
@ -162,7 +162,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
final Session s = openSession();
s.beginTransaction();
final SQLQuery query = (SQLQuery) s.getNamedQuery("namedQuery");
final NativeQuery query = (NativeQuery) s.getNamedQuery("namedQuery");
query.addScalar("c");
final Number result = (Number) query.uniqueResult();
s.getTransaction().commit();
@ -184,11 +184,11 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s.persist( jboss );
// now query on Employment, this should not cause an auto-flush
s.createSQLQuery( getEmploymentSQL() ).addSynchronizedQuerySpace( "ABC" ).list();
s.createNativeQuery( getEmploymentSQL() ).addSynchronizedQuerySpace( "ABC" ).list();
assertEquals( 0, sessionFactory().getStatistics().getEntityInsertCount() );
// now try to query on Employment but this time add Organization as a synchronized query space...
s.createSQLQuery( getEmploymentSQL() ).addSynchronizedEntityClass( Organization.class ).list();
s.createNativeQuery( getEmploymentSQL() ).addSynchronizedEntityClass( Organization.class ).list();
assertEquals( 1, sessionFactory().getStatistics().getEntityInsertCount() );
// clean up
@ -211,14 +211,14 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s.persist(gavin);
s.persist(emp);
List l = s.createSQLQuery( getOrgEmpRegionSQL() )
List l = s.createNativeQuery( getOrgEmpRegionSQL() )
.addEntity("org", Organization.class)
.addJoin("emp", "org.employments")
.addScalar("regionCode", StringType.INSTANCE)
.list();
assertEquals( 2, l.size() );
l = s.createSQLQuery( getOrgEmpPersonSQL() )
l = s.createNativeQuery( getOrgEmpPersonSQL() )
.addEntity("org", Organization.class)
.addJoin("emp", "org.employments")
.addJoin("pers", "emp.employee")
@ -231,7 +231,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
l = s.createSQLQuery( "select {org.*}, {emp.*} " +
l = s.createNativeQuery( "select {org.*}, {emp.*} " +
"from ORGANIZATION org " +
" left outer join EMPLOYMENT emp on org.ORGID = emp.EMPLOYER, ORGANIZATION org2" )
.addEntity("org", Organization.class)
@ -269,12 +269,12 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s.persist(gavin);
s.persist(emp);
List l = s.createSQLQuery( getOrgEmpRegionSQL() )
List l = s.createNativeQuery( getOrgEmpRegionSQL() )
.setResultSetMapping( "org-emp-regionCode" )
.list();
assertEquals( l.size(), 2 );
l = s.createSQLQuery( getOrgEmpPersonSQL() )
l = s.createNativeQuery( getOrgEmpPersonSQL() )
.setResultSetMapping( "org-emp-person" )
.list();
assertEquals( l.size(), 1 );
@ -490,7 +490,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
Object[] o = (Object[]) s.createSQLQuery( "select\r\n" +
Object[] o = (Object[]) s.createNativeQuery( "select\r\n" +
" product.orgid as {product.id.orgid}," +
" product.productnumber as {product.id.productnumber}," +
" {prod_orders}.orgid as orgid3_1_,\r\n" +
@ -538,7 +538,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
List list = s.createSQLQuery( getEmploymentSQL() )
List list = s.createNativeQuery( getEmploymentSQL() )
.addEntity( Employment.class.getName() )
.list();
assertEquals( 1,list.size() );
@ -550,7 +550,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s.clear();
list = s.createSQLQuery( getEmploymentSQL() )
list = s.createNativeQuery( getEmploymentSQL() )
.addEntity( Employment.class.getName() )
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)
.list();
@ -559,12 +559,12 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
assertTrue(m.containsKey("Employment"));
assertEquals(1,m.size());
list = s.createSQLQuery(getEmploymentSQL()).list();
list = s.createNativeQuery(getEmploymentSQL()).list();
assertEquals(1, list.size());
Object[] o = (Object[]) list.get(0);
assertEquals(8, o.length);
list = s.createSQLQuery( getEmploymentSQL() ).setResultTransformer( new UpperCasedAliasToEntityMapResultTransformer() ).list();
list = s.createNativeQuery( getEmploymentSQL() ).setResultTransformer( new UpperCasedAliasToEntityMapResultTransformer() ).list();
assertEquals(1, list.size());
m = (Map) list.get(0);
assertTrue(m.containsKey("EMPID"));
@ -572,7 +572,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
assertTrue(m.containsKey("ENDDATE"));
assertEquals(8, m.size());
list = s.createSQLQuery( getEmploymentSQLMixedScalarEntity() ).addScalar( "employerid" ).addEntity( Employment.class ).list();
list = s.createNativeQuery( getEmploymentSQLMixedScalarEntity() ).addScalar( "employerid" ).addEntity( Employment.class ).list();
assertEquals(1, list.size());
o = (Object[]) list.get(0);
assertEquals(2, o.length);
@ -588,7 +588,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s.clear();
list = s.createSQLQuery( getOrganizationJoinEmploymentSQL() )
list = s.createNativeQuery( getOrganizationJoinEmploymentSQL() )
.addEntity( "org", Organization.class )
.addJoin( "emp", "org.employments" )
.list();
@ -596,7 +596,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s.clear();
list = s.createSQLQuery( getOrganizationFetchJoinEmploymentSQL() )
list = s.createNativeQuery( getOrganizationFetchJoinEmploymentSQL() )
.addEntity( "org", Organization.class )
.addJoin( "emp", "org.employments" )
.list();
@ -631,7 +631,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
t = s.beginTransaction();
Dimension dim = new Dimension( 3, 30 );
s.save( dim );
list = s.createSQLQuery( "select d_len * d_width as surface, d_len * d_width * 10 as volume from Dimension" ).list();
list = s.createNativeQuery( "select d_len * d_width as surface, d_len * d_width * 10 as volume from Dimension" ).list();
s.delete( dim );
t.commit();
s.close();
@ -689,7 +689,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
" LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER";
// as a control, lets apply an existing rs mapping
SQLQuery sqlQuery = s.createSQLQuery( sql );
NativeQuery sqlQuery = s.createNativeQuery( sql );
sqlQuery.setResultSetMapping( "org-description" );
sqlQuery.list();
@ -750,7 +750,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s.flush();
s.clear();
List l = s.createSQLQuery( "select name, id, flength, name as scalarName from Speech" )
List l = s.createNativeQuery( "select name, id, flength, name as scalarName from Speech" )
.setResultSetMapping( "speech" )
.list();
assertEquals( l.size(), 1 );
@ -843,7 +843,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
String descriptionRead = ( String ) s.createSQLQuery( getDescriptionsSQL() )
String descriptionRead = ( String ) s.createNativeQuery( getDescriptionsSQL() )
.uniqueResult();
assertEquals( description, descriptionRead );
s.delete( holder );
@ -864,7 +864,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
byte[] photoRead = ( byte[] ) s.createSQLQuery( getPhotosSQL() )
byte[] photoRead = ( byte[] ) s.createNativeQuery( getPhotosSQL() )
.uniqueResult();
assertTrue( Arrays.equals( photo, photoRead ) );
s.delete( holder );
@ -876,7 +876,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
public void testEscapeColonInSQL() throws QueryException {
Session s = openSession();
Transaction t = s.beginTransaction();
SQLQuery query = s.createSQLQuery( "SELECT @row \\:= 1" );
NativeQuery query = s.createNativeQuery( "SELECT @row \\:= 1" );
List list = query.list();
assertTrue( list.get( 0 ).toString().equals( "1" ) );
t.commit();

View File

@ -8,9 +8,10 @@ package org.hibernate.test.sql.hand.quotedidentifiers;
import org.junit.Test;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.dialect.Dialect;
import org.hibernate.query.NativeQuery;
import org.hibernate.testing.DialectCheck;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -66,7 +67,7 @@ public class NativeSqlAndQuotedIdentifiersTest extends BaseCoreFunctionalTestCas
public void testPartialScalarDiscovery() {
Session session = openSession();
session.beginTransaction();
SQLQuery query = (SQLQuery) session.getNamedQuery( "query-person" );
NativeQuery query = (NativeQuery) session.getNamedQuery( "query-person" );
query.setResultSetMapping( "person-scalar" );
query.list();
session.getTransaction().commit();
@ -77,7 +78,7 @@ public class NativeSqlAndQuotedIdentifiersTest extends BaseCoreFunctionalTestCas
public void testBasicEntityMapping() {
Session session = openSession();
session.beginTransaction();
SQLQuery query = (SQLQuery) session.getNamedQuery( "query-person" );
NativeQuery query = (NativeQuery) session.getNamedQuery( "query-person" );
query.setResultSetMapping( "person-entity-basic" );
query.list();
session.getTransaction().commit();
@ -88,7 +89,7 @@ public class NativeSqlAndQuotedIdentifiersTest extends BaseCoreFunctionalTestCas
public void testExpandedEntityMapping() {
Session session = openSession();
session.beginTransaction();
SQLQuery query = (SQLQuery) session.getNamedQuery( "query-person" );
NativeQuery query = (NativeQuery) session.getNamedQuery( "query-person" );
query.setResultSetMapping( "person-entity-expanded" );
query.list();
session.getTransaction().commit();

View File

@ -14,7 +14,7 @@ import javax.persistence.Table;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.MySQL57Dialect;

View File

@ -15,12 +15,13 @@ import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.dialect.MySQL57Dialect;
import org.hibernate.type.TimestampType;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
@ -68,7 +69,8 @@ public class MySQL57TimestampPropertyTest extends BaseCoreFunctionalTestCase {
s = openSession();
s.getTransaction().begin();
final Query queryWithTimestamp = s.createQuery( "from Entity where ts= ?1" ).setTimestamp( 1, eOrig.ts );
final Query queryWithTimestamp = s.createQuery( "from Entity where ts= ?1" )
.setParameter( 1, eOrig.ts, TimestampType.INSTANCE );
final Entity eQueriedWithTimestamp = (Entity) queryWithTimestamp.uniqueResult();
assertNotNull( eQueriedWithTimestamp );
s.getTransaction().commit();

View File

@ -19,7 +19,7 @@ import javax.persistence.TemporalType;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.dialect.SQLServerDialect;

View File

@ -18,7 +18,7 @@ import javax.persistence.TemporalType;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Generated;

View File

@ -22,7 +22,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.dialect.MariaDBDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.SybaseDialect;

View File

@ -22,7 +22,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.dialect.MariaDBDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.SybaseDialect;

View File

@ -14,25 +14,18 @@ import org.junit.Test;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.SharedSessionContract;
import org.hibernate.Transaction;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Order;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.jdbc.Work;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jdbc.SQLServerSnapshotIsolationConnectionProvider;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.transaction.TransactionUtil;
import org.hibernate.testing.util.ExceptionUtil;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
@ -41,7 +34,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Gavin King

View File

@ -8,7 +8,7 @@ package org.hibernate.test.unionsubclass.alias;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.TestForIssue;