Stored Procedure added.
Added TestCase without using NamedStoredProcedure
This commit is contained in:
parent
3b5c46bbbf
commit
202a99786a
|
@ -0,0 +1,7 @@
|
|||
create or replace PROCEDURE FIND_CAR_BY_YEAR ( p_year IN NUMBER, data OUT SYS_REFCURSOR ) AS
|
||||
BEGIN
|
||||
OPEN data FOR
|
||||
SELECT ID, MODEL, YEAR
|
||||
FROM CAR
|
||||
WHERE YEAR = p_year;
|
||||
END FIND_CAR_BY_YEAR;
|
|
@ -1,4 +1,5 @@
|
|||
INSERT INTO CAR (ID, MODEL, YEAR) VALUES ('123456', 'Camaro', '2012');
|
||||
INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('12112', 'Fiat Panda', '2000')
|
||||
INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('111000', 'Fiat Punto', '2007')
|
||||
INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('3382', 'Citroen C3', '2009')
|
||||
INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('12112', 'Fiat Panda', '2000');
|
||||
INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('111000', 'Fiat Punto', '2007');
|
||||
INSERT INTO "JPA"."CAR" (ID, MODEL, YEAR) VALUES ('3382', 'Citroen C3', '2009');
|
||||
commit;
|
|
@ -53,6 +53,16 @@ public class StoredProcedureTest {
|
|||
storedProcedure.getResultList().forEach(c -> Assert.assertEquals("Camaro", ((Car) c).getModel()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findCarsByYearNoNamedStored() {
|
||||
StoredProcedureQuery findByYearProcedure =
|
||||
entityManager.createStoredProcedureQuery("FIND_CAR_BY_YEAR", Car.class)
|
||||
.registerStoredProcedureParameter("p_year", Integer.class, ParameterMode.IN)
|
||||
.registerStoredProcedureParameter("data", Void.class, ParameterMode.REF_CURSOR).setParameter("p_year", 2015);
|
||||
|
||||
findByYearProcedure.getResultList().forEach(c -> Assert.assertEquals(new Integer(2015), ((Car) c).getYear()));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void destroy() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue