use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall in project eclipselink by eclipse-ee4j.
the class PLSQLProject method buildAddressListOutQuery.
protected DatabaseQuery buildAddressListOutQuery() {
PLSQLrecord record = buildAddressRecord();
PLSQLCollection collection = new PLSQLCollection();
collection.setTypeName("PLSQL_P.PLSQL_ADDRESS_LIST");
collection.setCompatibleType("PLSQL_P_PLSQL_ADDRESS_LIST");
collection.setNestedType(record);
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
call.setProcedureName("PLSQL_P.PLSQL_ADDRESS_LIST_OUT");
call.addNamedOutputArgument("P_ADDRESS_LIST", collection);
call.addNamedOutputArgument("P_CITY", JDBCTypes.VARCHAR_TYPE);
DataReadQuery query = new DataReadQuery();
query.setCall(call);
return query;
}
use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall in project eclipselink by eclipse-ee4j.
the class PLSQLProject method buildEmployeeListInQuery.
protected DatabaseQuery buildEmployeeListInQuery() {
PLSQLrecord record = buildEmployeeRecord();
PLSQLCollection collection = new PLSQLCollection();
collection.setTypeName("PLSQL_P.PLSQL_EMP_LIST");
collection.setCompatibleType("PLSQL_P_PLSQL_EMP_LIST");
collection.setNestedType(record);
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
call.setProcedureName("PLSQL_P.PLSQL_EMP_LIST_IN");
call.addNamedArgument("P_EMP_LIST", collection);
call.addNamedArgument("P_CITY", JDBCTypes.VARCHAR_TYPE);
DataModifyQuery query = new DataModifyQuery();
query.addArgument("P_EMP_LIST", java.sql.Array.class);
query.addArgument("P_CITY", String.class);
query.setCall(call);
return query;
}
use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall in project eclipselink by eclipse-ee4j.
the class PLSQLTestSuite method testOracleTypeProcessing.
/**
* Test processing of OracleObject and OracleArray annotations.
*
* @see OracleArray
* @see org.eclipse.persistence.platform.database.oracle.annotations.OracleObject
*/
public void testOracleTypeProcessing() {
if (!getServerSession().getPlatform().isOracle()) {
return;
}
EntityManager em = createEntityManager();
beginTransaction(em);
try {
Query query = em.createNamedQuery("TEST_ORACLE_TYPES");
assertNotNull("EntityManager could not create query [TEST_ORACLE_TYPES]", query);
assertTrue("Expected EJBQueryImpl but was [" + query.getClass().getName() + "]", query instanceof EJBQueryImpl);
DatabaseCall call = ((EJBQueryImpl) query).getDatabaseQuery().getCall();
assertNotNull("The DatabaseCall was not set on the query", call);
assertTrue("Expected PLSQLStoredProcedureCall but was [" + call.getClass().getName() + "]", call instanceof PLSQLStoredProcedureCall);
PLSQLStoredProcedureCall plsqlCall = (PLSQLStoredProcedureCall) call;
List<PLSQLargument> args = plsqlCall.getArguments();
assertTrue("Expected 2 arguments, but was [" + args.size() + "]", args.size() == 2);
boolean foundINArg = false;
boolean foundOUTArg = false;
for (PLSQLargument arg : args) {
if (arg.name.equals("P_IN")) {
foundINArg = true;
assertNotNull("databaseType for arg P_IN is null", arg.databaseType);
assertTrue("Expected arg P_IN to be an OracleArrayType, but was [" + arg.databaseType.getClass().getName() + "]", arg.databaseType instanceof OracleArrayType);
OracleArrayType arrayType = (OracleArrayType) arg.databaseType;
assertTrue("Expected arg P_IN to have databaseType set with type name VARRAY_NUMERO_UNO, but was [" + arrayType.getTypeName() + "]", arrayType.getTypeName().equals("VARRAY_NUMERO_UNO"));
assertNotNull("Expected VARRAY_NUMERO_UNO to have nested type VARCHAR, but was null", arrayType.getNestedType());
assertTrue("Expected VARRAY_NUMERO_UNO to have nested type VARCHAR, but was [" + arrayType.getNestedType().getTypeName() + "]", arrayType.getNestedType().getTypeName().equals("VARCHAR"));
} else if (arg.name.equals("P_OUT")) {
foundOUTArg = true;
assertNotNull("databaseType for arg P_OUT is null", arg.databaseType);
assertTrue("Expected arg P_OUT to be an OracleObjectType, but was [" + arg.databaseType.getClass().getName() + "]", arg.databaseType instanceof OracleObjectType);
OracleObjectType objectType = (OracleObjectType) arg.databaseType;
assertTrue("Expected arg P_OUT to have databaseType set with type name OBJECT_NUMERO_DOS, but was [" + objectType.getTypeName() + "]", objectType.getTypeName().equals("OBJECT_NUMERO_DOS"));
assertTrue("Expected OBJECT_NUMERO_DOS to have 2 fields, but was [" + objectType.getFields().size() + "]", objectType.getFields().size() == 2);
for (String key : objectType.getFields().keySet()) {
DatabaseType dbType = objectType.getFields().get(key);
if (key.equals("OO_FLD1")) {
assertTrue("Expected field OO_FLD1 to have databaseType NUMERIC, but was [" + dbType.getTypeName() + "]", dbType.getTypeName().equals("NUMERIC"));
} else if (key.equals("OO_FLD2")) {
assertTrue("Expected field OO_FLD2 to have databaseType NUMERIC, but was [" + dbType.getTypeName() + "]", dbType.getTypeName().equals("NUMERIC"));
} else {
fail("Expected OBJECT_NUMERO_DOS to have fields OO_FLD1 and OO_FLD2 but encountered field [" + key + "]");
}
}
} else {
fail("Expected arg name to be one of P_IN or P_OUT, but was [" + arg.name + "]");
}
}
assertTrue("IN arg P_IN was not processed", foundINArg);
assertTrue("OUT arg P_OUT was not processed", foundOUTArg);
} finally {
closeEntityManagerAndTransaction(em);
}
}
use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall in project eclipselink by eclipse-ee4j.
the class NijioNijioTestSet method writeToXml.
@Test
public void writeToXml() {
// PROCEDURE NIJIONIJIO(X IN PLS_INTEGER, Y IN OUT NUMBER, Z IN BOOLEAN, AA IN OUT VARCHAR)
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
call.setProcedureName("NijioNijio");
call.addNamedArgument("X", OraclePLSQLTypes.PLSQLInteger);
call.addNamedInOutputArgument("Y", JDBCTypes.NUMERIC_TYPE, 22, 2);
call.addNamedArgument("Z", OraclePLSQLTypes.PLSQLBoolean);
call.addNamedInOutputArgument("AA", JDBCTypes.VARCHAR_TYPE, 10);
DataReadQuery query = new DataReadQuery();
query.addArgument("X", Integer.class);
query.addArgument("Y", BigDecimal.class);
query.addArgument("Z", Integer.class);
query.addArgument("AA", String.class);
query.setCall(call);
project.getDescriptor(Empty.class).getQueryManager().addQuery("NijioNijio", query);
Project projectToXml = project.clone();
// trim off login 'cause it changes under test - this way, a comparison
// can be done to a control document
projectToXml.setDatasourceLogin(null);
XMLContext context = new XMLContext(workbenchXMLProject);
XMLMarshaller marshaller = context.createMarshaller();
Document doc = marshaller.objectToXML(projectToXml);
Document controlDoc = xmlParser.parse(new StringReader(NIJIONIJIO_PROJECT_XML));
assertTrue("control document not same as instance document", comparer.isNodeEqual(controlDoc, doc));
}
use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall in project eclipselink by eclipse-ee4j.
the class Ni4TestSet method writeToXml.
@Test
public void writeToXml() {
// (y in dec)
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
call.setProcedureName("dec_in_test");
call.addNamedArgument("Y", OraclePLSQLTypes.Dec);
DataModifyQuery query = new DataModifyQuery();
query.addArgument("Y", Integer.class);
query.setCall(call);
project.getDescriptor(Empty.class).getQueryManager().addQuery("Ni4", query);
Project projectToXml = project.clone();
// trim off login 'cause it changes under test - this way, a comparison
// can be done to a control document
projectToXml.setDatasourceLogin(null);
XMLContext context = new XMLContext(workbenchXMLProject);
XMLMarshaller marshaller = context.createMarshaller();
Document doc = marshaller.objectToXML(projectToXml);
Document controlDoc = xmlParser.parse(new StringReader(NI4_PROJECT_XML));
assertTrue("control document not same as instance document", comparer.isNodeEqual(controlDoc, doc));
}
Aggregations