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