6 - SQM based on JPA type system
This commit is contained in:
parent
8f63e3176e
commit
711aaec3c9
|
@ -103,7 +103,7 @@ public class BatchFetchTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
s.clear();
|
||||
|
||||
Iterator iter = s.createQuery( "from Model" ).iterate();
|
||||
Iterator iter = s.createQuery( "from Model" ).list().iterator();
|
||||
list = new ArrayList();
|
||||
while ( iter.hasNext() ) {
|
||||
list.add( iter.next() );
|
||||
|
|
|
@ -19,6 +19,8 @@ import org.hibernate.Session;
|
|||
import org.hibernate.Transaction;
|
||||
import org.hibernate.dialect.AbstractHANADialect;
|
||||
import org.hibernate.dialect.Oracle10gDialect;
|
||||
import org.hibernate.type.DateType;
|
||||
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
@ -57,9 +59,9 @@ public class OneToOneLinkTest extends BaseCoreFunctionalTestCase {
|
|||
assertNull( e.getPerson().getCustomer() );
|
||||
s.clear();
|
||||
|
||||
e = (Employee) s.createQuery("from Employee e where e.person.dob = :date")
|
||||
.setDate("date", new Date() )
|
||||
.uniqueResult();
|
||||
e = (Employee) s.createQuery( "from Employee e where e.person.dob = :date" )
|
||||
.setParameter( "date", new Date(), DateType.INSTANCE )
|
||||
.uniqueResult();
|
||||
assertEquals( e.getPerson().getName(), "Gavin King" );
|
||||
assertFalse( Hibernate.isInitialized( e.getPerson() ) );
|
||||
assertNull( e.getPerson().getCustomer() );
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
package org.hibernate.test.ops;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -626,9 +629,7 @@ public class MergeTest extends AbstractOperationTestCase {
|
|||
s.beginTransaction();
|
||||
assertEquals(
|
||||
Long.valueOf( 2 ),
|
||||
s.createCriteria( NumberedNode.class )
|
||||
.setProjection( Projections.rowCount() )
|
||||
.uniqueResult()
|
||||
getNumneredNodeRowCount( s )
|
||||
);
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
@ -636,6 +637,14 @@ public class MergeTest extends AbstractOperationTestCase {
|
|||
cleanup();
|
||||
}
|
||||
|
||||
private Long getNumneredNodeRowCount(Session s ){
|
||||
CriteriaBuilder criteriaBuilder = s.getCriteriaBuilder();
|
||||
CriteriaQuery<Long> criteria = criteriaBuilder.createQuery( Long.class );
|
||||
Root<NumberedNode> root = criteria.from( NumberedNode.class );
|
||||
criteria.select( criteriaBuilder.count( root ) );
|
||||
return s.createQuery( criteria ).uniqueResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeManagedUninitializedCollection() {
|
||||
Session s = openSession();
|
||||
|
@ -669,9 +678,7 @@ public class MergeTest extends AbstractOperationTestCase {
|
|||
tx = s.beginTransaction();
|
||||
assertEquals(
|
||||
Long.valueOf( 2 ),
|
||||
s.createCriteria( NumberedNode.class )
|
||||
.setProjection( Projections.rowCount() )
|
||||
.uniqueResult()
|
||||
getNumneredNodeRowCount( s )
|
||||
);
|
||||
tx.commit();
|
||||
|
||||
|
@ -714,9 +721,7 @@ public class MergeTest extends AbstractOperationTestCase {
|
|||
tx = s.beginTransaction();
|
||||
assertEquals(
|
||||
Long.valueOf( 2 ),
|
||||
s.createCriteria(NumberedNode.class)
|
||||
.setProjection( Projections.rowCount() )
|
||||
.uniqueResult()
|
||||
getNumneredNodeRowCount( s )
|
||||
);
|
||||
tx.commit();
|
||||
|
||||
|
@ -749,7 +754,7 @@ public class MergeTest extends AbstractOperationTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAndMerge() throws Exception {
|
||||
public void testDeleteAndMerge() {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
Employer jboss = new Employer();
|
||||
|
@ -759,7 +764,7 @@ public class MergeTest extends AbstractOperationTestCase {
|
|||
|
||||
s.getTransaction().begin();
|
||||
Employer otherJboss;
|
||||
otherJboss = (Employer) s.get( Employer.class, jboss.getId() );
|
||||
otherJboss = s.get( Employer.class, jboss.getId() );
|
||||
s.delete( otherJboss );
|
||||
s.getTransaction().commit();
|
||||
s.clear();
|
||||
|
@ -775,7 +780,7 @@ public class MergeTest extends AbstractOperationTestCase {
|
|||
@SuppressWarnings( {"unchecked"})
|
||||
@Test
|
||||
@SkipForDialect(value = AbstractHANADialect.class, comment = " HANA doesn't support tables consisting of only a single auto-generated column")
|
||||
public void testMergeManyToManyWithCollectionDeference() throws Exception {
|
||||
public void testMergeManyToManyWithCollectionDeference() {
|
||||
// setup base data...
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
|
|
|
@ -82,7 +82,7 @@ public class NativeQueryScrollableResults extends BaseCoreFunctionalTestCase {
|
|||
.setParameter( "bigValues", params );
|
||||
try (ScrollableResults scroll = query.scroll()) {
|
||||
while ( scroll.next() ) {
|
||||
assertThat( scroll.get()[0], not( nullValue()) );
|
||||
assertThat( scroll.get(), not( nullValue()) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue