mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-27 22:39:13 +00:00
6 - SQM based on JPA type system
This commit is contained in:
parent
f436d18bf2
commit
3f3e4c24e8
@ -49,7 +49,7 @@ public void testDefaultAnyAssociation() {
|
||||
|
||||
Query q = s
|
||||
.createQuery( "select s from PropertySet s where name = :name" );
|
||||
q.setString( "name", "string" );
|
||||
q.setParameter( "name", "string" );
|
||||
PropertySet result = (PropertySet) q.uniqueResult();
|
||||
|
||||
assertNotNull( result );
|
||||
@ -60,7 +60,7 @@ public void testDefaultAnyAssociation() {
|
||||
assertEquals( 1, result.getGeneralProperties().size() );
|
||||
assertEquals( "Alex", result.getGeneralProperties().get( 0 ).asString() );
|
||||
|
||||
q.setString( "name", "integer" );
|
||||
q.setParameter( "name", "integer" );
|
||||
result = (PropertySet) q.uniqueResult();
|
||||
assertNotNull( result );
|
||||
assertNotNull( result.getSomeProperty() );
|
||||
@ -91,7 +91,7 @@ public void testManyToAnyWithMap() throws Exception {
|
||||
|
||||
Query q = s
|
||||
.createQuery( "SELECT map FROM PropertyMap map WHERE map.name = :name" );
|
||||
q.setString( "name", "sample" );
|
||||
q.setParameter( "name", "sample" );
|
||||
PropertyMap actualMap = (PropertyMap) q.uniqueResult();
|
||||
|
||||
assertNotNull( actualMap );
|
||||
@ -113,7 +113,7 @@ public void testManyToAnyWithMap() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaDataUseWithManyToAny() throws Exception {
|
||||
public void testMetaDataUseWithManyToAny() {
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
|
||||
@ -137,7 +137,7 @@ public void testMetaDataUseWithManyToAny() throws Exception {
|
||||
|
||||
Query q = s
|
||||
.createQuery( "SELECT list FROM PropertyList list WHERE list.name = :name" );
|
||||
q.setString( "name", "sample" );
|
||||
q.setParameter( "name", "sample" );
|
||||
PropertyList<Property> actualList = (PropertyList<Property>) q
|
||||
.uniqueResult();
|
||||
|
||||
|
@ -86,7 +86,7 @@ public void testManyToOneInCompositePk() throws Exception {
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.createQuery( "select c from Child c where c.id.nthChild = :nth" );
|
||||
q.setInteger( "nth", 1 );
|
||||
q.setParameter( "nth", 1 );
|
||||
List results = q.list();
|
||||
assertEquals( 1, results.size() );
|
||||
c = (Child) results.get( 0 );
|
||||
@ -173,7 +173,7 @@ public void testManyToOneInCompositePkAndSubclass() throws Exception {
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.createQuery( "select c from Child c where c.id.nthChild = :nth" );
|
||||
q.setInteger( "nth", 1 );
|
||||
q.setParameter( "nth", 1 );
|
||||
List results = q.list();
|
||||
assertEquals( 1, results.size() );
|
||||
c = (LittleGenius) results.get( 0 );
|
||||
|
@ -291,7 +291,7 @@ public void testManyToOneInsideComponent() throws Exception {
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.createQuery( "select p from Person p where p.address.city = :city" );
|
||||
q.setString( "city", add.city );
|
||||
q.setParameter( "city", add.city );
|
||||
List result = q.list();
|
||||
Person samePerson = (Person) result.get( 0 );
|
||||
assertNotNull( samePerson.address.type );
|
||||
|
@ -90,9 +90,9 @@ public void testEnums() throws Exception {
|
||||
assertEquals( Starred.OK, communityBid.getCommunityNote() );
|
||||
s.delete( bid );
|
||||
s.clear();
|
||||
communityBid = (CommunityBid) s.createSQLQuery( "select {b.*} from Bid b where b.id = ?" )
|
||||
communityBid = (CommunityBid) s.createNativeQuery( "select {b.*} from Bid b where b.id = ?" )
|
||||
.addEntity( "b", CommunityBid.class )
|
||||
.setInteger( 1, communityBid.getId() ).uniqueResult();
|
||||
.setParameter( 1, communityBid.getId() ).uniqueResult();
|
||||
assertEquals( Starred.OK, communityBid.getCommunityNote() );
|
||||
s.delete( communityBid );
|
||||
tx.commit();
|
||||
|
@ -80,7 +80,7 @@ public void test2ndLevelSubClass() throws Exception {
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.createQuery( "from " + A320.class.getName() + " as a where a.javaEmbeddedVersion = :version" );
|
||||
q.setString( "version", "Elephant" );
|
||||
q.setParameter( "version", "Elephant" );
|
||||
List a320s = q.list();
|
||||
assertNotNull( a320s );
|
||||
assertEquals( 1, a320s.size() );
|
||||
|
@ -106,7 +106,7 @@ private long getTableRowCount(Session s, String tableName) {
|
||||
// the type returned for count(*) in a native query depends on the dialect
|
||||
// Oracle returns Types.NUMERIC, which is mapped to BigDecimal;
|
||||
// H2 returns Types.BIGINT, which is mapped to BigInteger;
|
||||
Object retVal = s.createSQLQuery( "select count(*) from " + tableName ).uniqueResult();
|
||||
Object retVal = s.createNativeQuery( "select count(*) from " + tableName ).uniqueResult();
|
||||
assertTrue( Number.class.isInstance( retVal ) );
|
||||
return ( ( Number ) retVal ).longValue();
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
import org.hibernate.stat.Statistics;
|
||||
import org.hibernate.type.DateType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
@ -316,10 +317,10 @@ public void testClassQueries() throws Exception {
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.getNamedQuery( "night.moreRecentThan" );
|
||||
q.setDate( "date", aMonthAgo );
|
||||
q.setParameter( "date", aMonthAgo, DateType.INSTANCE );
|
||||
assertEquals( 1, q.list().size() );
|
||||
q = s.getNamedQuery( "night.moreRecentThan" );
|
||||
q.setDate( "date", inAMonth );
|
||||
q.setParameter( "date", inAMonth, DateType.INSTANCE );
|
||||
assertEquals( 0, q.list().size() );
|
||||
Statistics stats = sessionFactory().getStatistics();
|
||||
stats.setStatisticsEnabled( true );
|
||||
|
@ -33,11 +33,10 @@ private void prepareTestData() {
|
||||
char open = getDialect().openQuote();
|
||||
char close = getDialect().closeQuote();
|
||||
queryString="select t."+open+"NAME"+close+" as "+open+"QuotEd_nAMe"+close+" from "+open+"MY_ENTITY_TABLE"+close+" t";
|
||||
Session s = sessionFactory().openSession();
|
||||
s.beginTransaction();
|
||||
s.save( new MyEntity( "mine" ) );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
s -> s.save( new MyEntity( "mine" ) )
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,24 +48,19 @@ protected boolean isCleanupTestDataRequired() {
|
||||
public void testCompleteScalarAutoDiscovery() {
|
||||
prepareTestData();
|
||||
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
s.createSQLQuery( queryString )
|
||||
.list();
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
s -> s.createNativeQuery( queryString ).list()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialScalarAutoDiscovery() {
|
||||
prepareTestData();
|
||||
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
s.createSQLQuery( queryString )
|
||||
.setResultSetMapping( "explicitScalarResultSetMapping" )
|
||||
.list();
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
s -> s.createNativeQuery( queryString )
|
||||
.setResultSetMapping( "explicitScalarResultSetMapping" )
|
||||
.list()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public void testUnionSubClass() throws Exception {
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.createQuery( "from Machine m where m.weight >= :weight" );
|
||||
q.setDouble( "weight", new Double( 10 ) );
|
||||
q.setParameter( "weight", new Double( 10 ) );
|
||||
List result = q.list();
|
||||
assertEquals( 2, result.size() );
|
||||
tx.commit();
|
||||
|
@ -6,9 +6,10 @@
|
||||
*/
|
||||
package org.hibernate.test.collection.custom.basic;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
@ -28,36 +29,40 @@ protected String getCacheConcurrencyStrategy() {
|
||||
|
||||
@Test
|
||||
public void testBasicOperation() {
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
User u = new User("max");
|
||||
u.getEmailAddresses().add( new Email("max@hibernate.org") );
|
||||
u.getEmailAddresses().add( new Email("max.andersen@jboss.com") );
|
||||
s.persist(u);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
User u2 = (User) s.createCriteria(User.class).uniqueResult();
|
||||
assertTrue( Hibernate.isInitialized( u2.getEmailAddresses() ) );
|
||||
assertEquals( u2.getEmailAddresses().size(), 2 );
|
||||
t.commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
s -> {
|
||||
u.getEmailAddresses().add( new Email("max@hibernate.org") );
|
||||
u.getEmailAddresses().add( new Email("max.andersen@jboss.com") );
|
||||
s.persist(u);
|
||||
}
|
||||
);
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
u2 = ( User ) s.get( User.class, u.getUserName() );
|
||||
u2.getEmailAddresses().size();
|
||||
assertEquals( 2, MyListType.lastInstantiationRequest );
|
||||
t.commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
s -> {
|
||||
CriteriaBuilder criteriaBuilder = s.getCriteriaBuilder();
|
||||
CriteriaQuery<User> criteria = criteriaBuilder.createQuery( User.class );
|
||||
criteria.from( User.class );
|
||||
User u2 = s.createQuery( criteria ).uniqueResult();
|
||||
// User u2 = (User) s.createCriteria(User.class).uniqueResult();
|
||||
assertTrue( Hibernate.isInitialized( u2.getEmailAddresses() ) );
|
||||
assertEquals( u2.getEmailAddresses().size(), 2 );
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
s.delete( u );
|
||||
t.commit();
|
||||
s.close();
|
||||
}
|
||||
);
|
||||
|
||||
inTransaction(
|
||||
s -> {
|
||||
User u2 = s.get( User.class, u.getUserName() );
|
||||
u2.getEmailAddresses().size();
|
||||
assertEquals( 2, MyListType.lastInstantiationRequest );
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
inTransaction(
|
||||
s -> s.delete( u )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -64,69 +64,67 @@ public void testTupleReturnFails() {
|
||||
@SkipForDialect(value = SybaseASE15Dialect.class , jiraKey = "HHH-5229")
|
||||
@SkipForDialect(value = { AbstractHANADialect.class }, comment = "HANA only supports forward-only cursors.")
|
||||
public void testScrollingJoinFetchesEmptyResultSet() {
|
||||
Session s = openSession();
|
||||
Transaction txn = s.beginTransaction();
|
||||
inTransaction(
|
||||
s -> {
|
||||
final String query = "from Animal a left join fetch a.offspring where a.description like :desc order by a.id";
|
||||
|
||||
final String query = "from Animal a left join fetch a.offspring where a.description like :desc order by a.id";
|
||||
// first, as a control, make sure there are no results
|
||||
int size = s.createQuery( query ).setParameter( "desc", "root%" ).list().size();
|
||||
assertEquals( 0, size );
|
||||
|
||||
// first, as a control, make sure there are no results
|
||||
int size = s.createQuery( query ).setString( "desc", "root%" ).list().size();
|
||||
assertEquals( 0, size );
|
||||
// now get the scrollable results
|
||||
ScrollableResults results = s.createQuery( query ).setParameter( "desc", "root%" ).scroll();
|
||||
|
||||
// now get the scrollable results
|
||||
ScrollableResults results = s.createQuery( query ).setString( "desc", "root%" ).scroll();
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
|
||||
assertFalse( results.next() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.previous() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
|
||||
assertFalse( results.previous() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
results.beforeFirst();
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
|
||||
results.beforeFirst();
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
assertFalse( results.first() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
|
||||
assertFalse( results.first() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
results.afterLast();
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
|
||||
results.afterLast();
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
assertFalse( results.last() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
|
||||
assertFalse( results.last() );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.next() );
|
||||
for ( int i=1; i<3; i++ ) {
|
||||
assertFalse( results.scroll( i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
|
||||
for ( int i=1; i<3; i++ ) {
|
||||
assertFalse( results.scroll( i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.scroll( - i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
|
||||
assertFalse( results.scroll( - i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
assertFalse( results.setRowNumber( i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
|
||||
assertFalse( results.setRowNumber( i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
|
||||
assertFalse( results.setRowNumber( - i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
s.close();
|
||||
assertFalse( results.setRowNumber( - i ) );
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -157,12 +155,12 @@ public void testScrollingJoinFetchesSingleRowResultSet() {
|
||||
|
||||
assertNotNull(s
|
||||
.createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
|
||||
.setString( "desc", "root%" )
|
||||
.setParameter( "desc", "root%" )
|
||||
.uniqueResult() );
|
||||
|
||||
ScrollableResults results = s
|
||||
.createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
|
||||
.setString( "desc", "root%" ).scroll();
|
||||
.setParameter( "desc", "root%" ).scroll();
|
||||
|
||||
assertFalse( results.isFirst() );
|
||||
assertFalse( results.isLast() );
|
||||
@ -262,24 +260,23 @@ public void testScrollingJoinFetchesForward() {
|
||||
TestData data = new TestData();
|
||||
data.prepare();
|
||||
|
||||
Session s = openSession();
|
||||
Transaction txn = s.beginTransaction();
|
||||
inTransaction(
|
||||
s -> {
|
||||
ScrollableResults results = s
|
||||
.createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
|
||||
.setParameter( "desc", "root%" )
|
||||
.scroll( ScrollMode.FORWARD_ONLY );
|
||||
|
||||
ScrollableResults results = s
|
||||
.createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
|
||||
.setString( "desc", "root%" )
|
||||
.scroll( ScrollMode.FORWARD_ONLY );
|
||||
int counter = 0;
|
||||
while ( results.next() ) {
|
||||
counter++;
|
||||
Animal animal = ( Animal ) results.get();
|
||||
checkResult( animal );
|
||||
}
|
||||
assertEquals( "unexpected result count", 2, counter );
|
||||
|
||||
int counter = 0;
|
||||
while ( results.next() ) {
|
||||
counter++;
|
||||
Animal animal = ( Animal ) results.get( 0 );
|
||||
checkResult( animal );
|
||||
}
|
||||
assertEquals( "unexpected result count", 2, counter );
|
||||
|
||||
txn.commit();
|
||||
s.close();
|
||||
}
|
||||
);
|
||||
|
||||
data.cleanup();
|
||||
}
|
||||
@ -292,26 +289,25 @@ public void testScrollingJoinFetchesReverse() {
|
||||
TestData data = new TestData();
|
||||
data.prepare();
|
||||
|
||||
Session s = openSession();
|
||||
Transaction txn = s.beginTransaction();
|
||||
inTransaction(
|
||||
s -> {
|
||||
ScrollableResults results = s
|
||||
.createQuery(
|
||||
"from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
|
||||
.setParameter( "desc", "root%" ).scroll();
|
||||
|
||||
ScrollableResults results = s
|
||||
.createQuery(
|
||||
"from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
|
||||
.setString( "desc", "root%" ).scroll();
|
||||
results.afterLast();
|
||||
|
||||
results.afterLast();
|
||||
int counter = 0;
|
||||
while ( results.previous() ) {
|
||||
counter++;
|
||||
Animal animal = ( Animal ) results.get( );
|
||||
checkResult( animal );
|
||||
}
|
||||
assertEquals( "unexpected result count", 2, counter );
|
||||
|
||||
int counter = 0;
|
||||
while ( results.previous() ) {
|
||||
counter++;
|
||||
Animal animal = ( Animal ) results.get( 0 );
|
||||
checkResult( animal );
|
||||
}
|
||||
assertEquals( "unexpected result count", 2, counter );
|
||||
|
||||
txn.commit();
|
||||
s.close();
|
||||
}
|
||||
);
|
||||
|
||||
data.cleanup();
|
||||
}
|
||||
@ -329,27 +325,27 @@ public void testScrollingJoinFetchesPositioning() {
|
||||
|
||||
ScrollableResults results = s
|
||||
.createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
|
||||
.setString( "desc", "root%" )
|
||||
.setParameter( "desc", "root%" )
|
||||
.scroll();
|
||||
|
||||
results.first();
|
||||
Animal animal = ( Animal ) results.get( 0 );
|
||||
Animal animal = ( Animal ) results.get( );
|
||||
assertEquals( "first() did not return expected row", data.root1Id, animal.getId() );
|
||||
|
||||
results.scroll( 1 );
|
||||
animal = ( Animal ) results.get( 0 );
|
||||
animal = ( Animal ) results.get( );
|
||||
assertEquals( "scroll(1) did not return expected row", data.root2Id, animal.getId() );
|
||||
|
||||
results.scroll( -1 );
|
||||
animal = ( Animal ) results.get( 0 );
|
||||
animal = ( Animal ) results.get( );
|
||||
assertEquals( "scroll(-1) did not return expected row", data.root1Id, animal.getId() );
|
||||
|
||||
results.setRowNumber( 1 );
|
||||
animal = ( Animal ) results.get( 0 );
|
||||
animal = ( Animal ) results.get();
|
||||
assertEquals( "setRowNumber(1) did not return expected row", data.root1Id, animal.getId() );
|
||||
|
||||
results.setRowNumber( 2 );
|
||||
animal = ( Animal ) results.get( 0 );
|
||||
animal = ( Animal ) results.get();
|
||||
assertEquals( "setRowNumber(2) did not return expected row", data.root2Id, animal.getId() );
|
||||
|
||||
txn.commit();
|
||||
|
@ -86,10 +86,10 @@ public void testScrollableResults() {
|
||||
int i = 0;
|
||||
while ( scroll.next() ) {
|
||||
if ( i == 0 ) {
|
||||
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_1" ) );
|
||||
assertThat( ((MyEntity) scroll.get()).getDescription(), is( "entity_1" ) );
|
||||
}
|
||||
else {
|
||||
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_2" ) );
|
||||
assertThat( ((MyEntity) scroll.get()).getDescription(), is( "entity_2" ) );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -112,10 +112,10 @@ public void testScrollableResults2() {
|
||||
int i = 0;
|
||||
while ( scroll.next() ) {
|
||||
if ( i == 0 ) {
|
||||
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_1" ) );
|
||||
assertThat( ((MyEntity) scroll.get()).getDescription(), is( "entity_1" ) );
|
||||
}
|
||||
else {
|
||||
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_2" ) );
|
||||
assertThat( ((MyEntity) scroll.get()).getDescription(), is( "entity_2" ) );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.NonContextualLobCreator;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.type.MaterializedNClobType;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
@ -87,6 +88,11 @@ public MockWrapperOptions(boolean useStreamForLobBinding) {
|
||||
this.useStreamForLobBinding = useStreamForLobBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedSessionContractImplementor getSession() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useStreamForLobBinding() {
|
||||
return useStreamForLobBinding;
|
||||
|
@ -84,7 +84,7 @@ public void testSaveEntityWithNationalizedProperty() {
|
||||
s = openSession();
|
||||
try {
|
||||
final Query query = s.createQuery( "from NationalizedEntity where name = :name" );
|
||||
query.setString( "name", "Hello" );
|
||||
query.setParameter( "name", "Hello" );
|
||||
final List list = query.list();
|
||||
assertThat( list.size(), is( 1 ) );
|
||||
}
|
||||
|
@ -8,9 +8,6 @@
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -96,8 +93,7 @@ public void testManyToOneNaturalIdCached() {
|
||||
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
CriteriaQuery<NaturalIdOnManyToOne> query = s.getCriteriaBuilder().createQuery( NaturalIdOnManyToOne.class );
|
||||
query.
|
||||
Criteria criteria = s.createCriteria( NaturalIdOnManyToOne.class );
|
||||
criteria.add( Restrictions.naturalId().set( "citizen", c1 ) );
|
||||
criteria.setCacheable( true );
|
||||
|
Loading…
x
Reference in New Issue
Block a user