use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord in project eclipselink by eclipse-ee4j.
the class PLSQLProject method buildAddressRecord.
protected PLSQLrecord buildAddressRecord() {
PLSQLrecord record = new PLSQLrecord();
record.setTypeName("PLSQL_P.PLSQL_ADDRESS_REC");
record.setCompatibleType("PLSQL_P_PLSQL_ADDRESS_REC");
record.addField("ADDRESS_ID", JDBCTypes.NUMERIC_TYPE, 10, 0);
record.addField("STREET_NUM", JDBCTypes.NUMERIC_TYPE, 10, 0);
record.addField("STREET", JDBCTypes.VARCHAR_TYPE, 30);
record.addField("CITY", JDBCTypes.VARCHAR_TYPE, 30);
record.addField("STATE", JDBCTypes.VARCHAR_TYPE, 30);
record.setJavaType(Address.class);
return record;
}
use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord 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.PLSQLrecord 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.PLSQLrecord in project eclipselink by eclipse-ee4j.
the class PLSQLrecordWithCompatibleTypeInOutTestSet method writeToXml.
@Test
public void writeToXml() {
PLSQLrecord r1 = new PLSQLrecord();
r1.setTypeName("emp%ROWTYPE");
r1.setCompatibleType("EMP_TYPE");
r1.addField("EMPNO", JDBCTypes.NUMERIC_TYPE, 4, 0);
r1.addField("ENAME", JDBCTypes.VARCHAR_TYPE, 10);
r1.addField("JOB", JDBCTypes.VARCHAR_TYPE, 9);
r1.addField("MGR", JDBCTypes.NUMERIC_TYPE, 4, 0);
r1.addField("HIREDATE", JDBCTypes.DATE_TYPE);
r1.addField("SAL", JDBCTypes.FLOAT_TYPE, 7, 2);
r1.addField("COMM", JDBCTypes.NUMERIC_TYPE, 7, 2);
r1.addField("DEPTNO", JDBCTypes.NUMERIC_TYPE, 2, 0);
// PROCEDURE REC_TEST_INOUT(Z IN OUT EMP%ROWTYPE)
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
call.setProcedureName("REC_TEST_INOUT");
call.addNamedInOutputArgument("Z", r1);
ReadObjectQuery query = new ReadObjectQuery(PLSQLEmployeeType.class);
query.addArgument("Z", Struct.class);
query.doNotCacheQueryResults();
query.dontMaintainCache();
query.setCall(call);
project.getDescriptor(PLSQLEmployeeType.class).getQueryManager().addQuery("PLSQLrecordWithCompatibleTypeInOut", 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(PLSQLRECORD_WITHCOMPATIBLETYPE_INOUT_PROJECT_XML));
assertTrue("control document not same as instance document", comparer.isNodeEqual(controlDoc, doc));
}
use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord in project eclipselink by eclipse-ee4j.
the class PLSQLrecordWithCompatibleTypeOutTestSet method writeToXml.
@Test
public void writeToXml() {
PLSQLrecord r1 = new PLSQLrecord();
r1.setTypeName("emp%ROWTYPE");
r1.setCompatibleType("EMP_TYPE");
r1.addField("EMPNO", JDBCTypes.NUMERIC_TYPE, 4, 0);
r1.addField("ENAME", JDBCTypes.VARCHAR_TYPE, 10);
r1.addField("JOB", JDBCTypes.VARCHAR_TYPE, 9);
r1.addField("MGR", JDBCTypes.NUMERIC_TYPE, 4, 0);
r1.addField("HIREDATE", JDBCTypes.DATE_TYPE);
r1.addField("SAL", JDBCTypes.FLOAT_TYPE, 7, 2);
r1.addField("COMM", JDBCTypes.NUMERIC_TYPE, 7, 2);
r1.addField("DEPTNO", JDBCTypes.NUMERIC_TYPE, 2, 0);
// PROCEDURE REC_TEST_OUT(Z OUT EMP%ROWTYPE)
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
call.setProcedureName("REC_TEST_OUT");
call.addNamedOutputArgument("Z", r1);
ReadObjectQuery query = new ReadObjectQuery(PLSQLEmployeeType.class);
query.doNotCacheQueryResults();
query.dontMaintainCache();
query.setCall(call);
project.getDescriptor(PLSQLEmployeeType.class).getQueryManager().addQuery("PLSQLrecordWithCompatibleTypeOut", 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(PLSQLRECORD_WITHCOMPATIBLETYPE_OUT_PROJECT_XML));
assertTrue("control document not same as instance document", comparer.isNodeEqual(controlDoc, doc));
}
Aggregations