minor fixes for function call tests
This commit is contained in:
parent
dd41ebc3cf
commit
bab5b2bf99
|
@ -378,40 +378,12 @@ public class OracleStoredProcedureTest {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNamedNativeQueryStoredProcedureRefCursor(EntityManagerFactoryScope scope) {
|
|
||||||
scope.inTransaction(
|
|
||||||
entityManager -> {
|
|
||||||
try {
|
|
||||||
List<Object[]> postAndComments = entityManager
|
|
||||||
.createNamedQuery(
|
|
||||||
"fn_person_and_phones" )
|
|
||||||
.setParameter( 1, 1L )
|
|
||||||
.getResultList();
|
|
||||||
Object[] postAndComment = postAndComments.get( 0 );
|
|
||||||
Person person = (Person) postAndComment[0];
|
|
||||||
Phone phone = (Phone) postAndComment[1];
|
|
||||||
assertEquals( 2, postAndComments.size() );
|
|
||||||
fail( "expected UnsupportedOperationException" );
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
assertThat( ex.getCause(), instanceOf( UnsupportedOperationException.class ) );
|
|
||||||
assertEquals(
|
|
||||||
"Recognizing native query as a function call is no longer supported",
|
|
||||||
ex.getCause().getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamedProcedureCallStoredProcedureRefCursor(EntityManagerFactoryScope scope) {
|
public void testNamedProcedureCallStoredProcedureRefCursor(EntityManagerFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
entityManager -> {
|
entityManager -> {
|
||||||
List<Object[]> postAndComments = entityManager
|
List<Object[]> postAndComments = entityManager
|
||||||
.createNamedStoredProcedureQuery(
|
.createNamedStoredProcedureQuery( "personAndPhonesFunction" )
|
||||||
"fn_person_and_phones_sq" )
|
|
||||||
.setParameter( 1, 1L )
|
.setParameter( 1, 1L )
|
||||||
.getResultList();
|
.getResultList();
|
||||||
Object[] postAndComment = postAndComments.get( 0 );
|
Object[] postAndComment = postAndComments.get( 0 );
|
||||||
|
@ -423,7 +395,7 @@ public class OracleStoredProcedureTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamedNativeQueryStoredProcedureRefCursorWithJDBC(EntityManagerFactoryScope scope) {
|
public void testFunctionCallWithJdbc(EntityManagerFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
entityManager -> {
|
entityManager -> {
|
||||||
Session session = entityManager.unwrap( Session.class );
|
Session session = entityManager.unwrap( Session.class );
|
||||||
|
|
|
@ -442,7 +442,7 @@ public class HANAStoredProcedureTest extends BaseEntityManagerFunctionalTestCase
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-12138")
|
@TestForIssue(jiraKey = "HHH-12138")
|
||||||
public void testNamedNativeQueryStoredProcedureRefCursorWithJDBC() {
|
public void testFunctionCallWithJDBC() {
|
||||||
EntityManager entityManager = createEntityManager();
|
EntityManager entityManager = createEntityManager();
|
||||||
entityManager.getTransaction().begin();
|
entityManager.getTransaction().begin();
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.annotations.NamedNativeQuery;
|
import org.hibernate.annotations.NamedNativeQuery;
|
||||||
|
import org.hibernate.jpa.AvailableHints;
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
@ -34,30 +35,22 @@ import static org.hibernate.jpa.HibernateHints.HINT_CALLABLE_FUNCTION;
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@NamedNativeQuery(
|
@NamedStoredProcedureQuery(
|
||||||
name = "fn_person_and_phones",
|
name = "personAndPhonesFunction",
|
||||||
query = "{ ? = call fn_person_and_phones( ? ) }",
|
procedureName = "fn_person_and_phones",
|
||||||
callable = true,
|
resultSetMappings = "personWithPhonesMapping",
|
||||||
resultSetMapping = "person_with_phones"
|
parameters = @StoredProcedureParameter(type = Long.class),
|
||||||
|
hints = @QueryHint(name = HINT_CALLABLE_FUNCTION, value = "true")
|
||||||
)
|
)
|
||||||
@NamedNativeQuery(
|
@NamedNativeQuery(
|
||||||
name = "fn_person_and_phones_hana",
|
name = "fn_person_and_phones_hana",
|
||||||
query = "select \"pr.id\", \"pr.name\", \"pr.nickName\", \"pr.address\", \"pr.createdOn\", \"pr.version\", \"ph.id\", \"ph.person_id\", \"ph.phone_number\", \"ph.valid\" from fn_person_and_phones( ? )",
|
query = "select \"pr.id\", \"pr.name\", \"pr.nickName\", \"pr.address\", \"pr.createdOn\", \"pr.version\", \"ph.id\", \"ph.person_id\", \"ph.phone_number\", \"ph.valid\" from fn_person_and_phones( ? )",
|
||||||
callable = false,
|
callable = false,
|
||||||
resultSetMapping = "person_with_phones_hana"
|
resultSetMapping = "person_with_phones_hana"
|
||||||
)
|
|
||||||
@NamedStoredProcedureQuery(
|
|
||||||
name = "fn_person_and_phones_sq",
|
|
||||||
procedureName = "fn_person_and_phones",
|
|
||||||
resultSetMappings = "person_with_phones",
|
|
||||||
parameters = {
|
|
||||||
@StoredProcedureParameter(type = Long.class)
|
|
||||||
},
|
|
||||||
hints = @QueryHint(name = HINT_CALLABLE_FUNCTION, value = "true")
|
|
||||||
)
|
)
|
||||||
@SqlResultSetMappings({
|
@SqlResultSetMappings({
|
||||||
@SqlResultSetMapping(
|
@SqlResultSetMapping(
|
||||||
name = "person_with_phones",
|
name = "personWithPhonesMapping",
|
||||||
entities = {
|
entities = {
|
||||||
@EntityResult(
|
@EntityResult(
|
||||||
entityClass = Person.class,
|
entityClass = Person.class,
|
||||||
|
|
Loading…
Reference in New Issue