Search in sources :

Example 16 with PLSQLrecord

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord in project eclipselink by eclipse-ee4j.

the class PLSQLrecordInOutTestSet method writeToXml.

@Test
public void writeToXml() {
    PLSQLrecord r1 = new PLSQLrecord();
    r1.setTypeName("emp%ROWTYPE");
    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("EMPNO", BigDecimal.class);
    query.addArgument("ENAME", String.class);
    query.addArgument("JOB", String.class);
    query.addArgument("MGR", BigDecimal.class);
    query.addArgument("HIREDATE", java.sql.Date.class);
    query.addArgument("SAL", Float.class);
    query.addArgument("COMM", BigDecimal.class);
    query.addArgument("DEPTNO", BigDecimal.class);
    query.doNotCacheQueryResults();
    query.dontMaintainCache();
    query.setCall(call);
    project.getDescriptor(PLSQLEmployeeType.class).getQueryManager().addQuery("PLSQLrecordInOut", 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_INOUT_PROJECT_XML));
    assertTrue("control document not same as instance document", comparer.isNodeEqual(controlDoc, doc));
}
Also used : ObjectPersistenceWorkbenchXMLProject(org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject) Project(org.eclipse.persistence.sessions.Project) PLSQLrecordTestHelper.buildTestProject(org.eclipse.persistence.testing.tests.plsqlrecord.PLSQLrecordTestHelper.buildTestProject) PLSQLrecordTestHelper.buildWorkbenchXMLProject(org.eclipse.persistence.testing.tests.plsqlrecord.PLSQLrecordTestHelper.buildWorkbenchXMLProject) PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) XMLContext(org.eclipse.persistence.oxm.XMLContext) XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) PLSQLrecord(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord) StringReader(java.io.StringReader) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 17 with PLSQLrecord

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord in project eclipselink by eclipse-ee4j.

the class PLSQLrecordInTestSet method writeToXml.

@Test
public void writeToXml() {
    // PROCEDURE REC_TEST(Z IN EMP%ROWTYPE)
    PLSQLrecord r1 = new PLSQLrecord();
    r1.setTypeName("emp%ROWTYPE");
    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);
    PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
    call.setProcedureName("REC_TEST");
    call.addNamedArgument("Z", r1);
    DataModifyQuery query = new DataModifyQuery();
    query.addArgument("EMPNO", BigDecimal.class);
    query.addArgument("ENAME", String.class);
    query.addArgument("JOB", String.class);
    query.addArgument("MGR", BigDecimal.class);
    query.addArgument("HIREDATE", java.sql.Date.class);
    query.addArgument("SAL", Float.class);
    query.addArgument("COMM", BigDecimal.class);
    query.addArgument("DEPTNO", BigDecimal.class);
    query.setCall(call);
    project.getDescriptor(PLSQLEmployeeType.class).getQueryManager().addQuery("PLSQLrecordIn", 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_IN_PROJECT_XML));
    assertTrue("control document not same as instance document", comparer.isNodeEqual(controlDoc, doc));
}
Also used : ObjectPersistenceWorkbenchXMLProject(org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject) Project(org.eclipse.persistence.sessions.Project) PLSQLrecordTestHelper.buildTestProject(org.eclipse.persistence.testing.tests.plsqlrecord.PLSQLrecordTestHelper.buildTestProject) PLSQLrecordTestHelper.buildWorkbenchXMLProject(org.eclipse.persistence.testing.tests.plsqlrecord.PLSQLrecordTestHelper.buildWorkbenchXMLProject) PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) XMLContext(org.eclipse.persistence.oxm.XMLContext) XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) PLSQLrecord(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord) StringReader(java.io.StringReader) Document(org.w3c.dom.Document) DataModifyQuery(org.eclipse.persistence.queries.DataModifyQuery) Test(org.junit.Test)

Example 18 with PLSQLrecord

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord in project eclipselink by eclipse-ee4j.

the class PLSQLProject method buildAddressInOutDataQuery.

protected DatabaseQuery buildAddressInOutDataQuery() {
    PLSQLrecord record = buildAddressRowTypeDataRecord();
    PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
    call.setProcedureName("PLSQL_ADDRESS_INOUT_DATA");
    call.addNamedInOutputArgument("P_ADDRESS", record);
    call.addNamedInOutputArgument("P_LOCAL", JDBCTypes.VARCHAR_TYPE, 30);
    DataReadQuery query = new DataReadQuery();
    query.addArgument("ADDRESS_ID", BigDecimal.class);
    query.addArgument("STREET_NUM", Integer.class);
    query.addArgument("STREET", String.class);
    query.addArgument("CITY", String.class);
    query.addArgument("STATE", String.class);
    query.addArgument("P_LOCAL", String.class);
    query.setCall(call);
    return query;
}
Also used : PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) PLSQLrecord(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord) DataReadQuery(org.eclipse.persistence.queries.DataReadQuery)

Example 19 with PLSQLrecord

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord in project eclipselink by eclipse-ee4j.

the class PLSQLProject method buildAddressInDataQuery.

protected DatabaseQuery buildAddressInDataQuery() {
    PLSQLrecord record = buildAddressRowTypeDataRecord();
    PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
    call.setProcedureName("PLSQL_ADDRESS_IN_DATA");
    call.addNamedArgument("P_LOCAL", JDBCTypes.VARCHAR_TYPE, 30);
    call.addNamedArgument("P_ADDRESS", record);
    DataModifyQuery query = new DataModifyQuery();
    query.addArgument("ADDRESS_ID", BigDecimal.class);
    query.addArgument("STREET_NUM", Integer.class);
    query.addArgument("STREET", String.class);
    query.addArgument("CITY", String.class);
    query.addArgument("STATE", String.class);
    query.addArgument("P_LOCAL", String.class);
    query.setCall(call);
    return query;
}
Also used : PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) PLSQLrecord(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord) DataModifyQuery(org.eclipse.persistence.queries.DataModifyQuery)

Example 20 with PLSQLrecord

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord in project eclipselink by eclipse-ee4j.

the class PLSQLProject method buildAddressListInOutQuery.

protected DatabaseQuery buildAddressListInOutQuery() {
    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_INOUT");
    call.addNamedInOutputArgument("P_ADDRESS_LIST", collection);
    call.addNamedInOutputArgument("P_CITY", JDBCTypes.VARCHAR_TYPE);
    DataReadQuery query = new DataReadQuery();
    query.addArgument("P_ADDRESS_LIST", java.sql.Array.class);
    query.addArgument("P_CITY", String.class);
    query.setCall(call);
    return query;
}
Also used : PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) PLSQLCollection(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection) PLSQLrecord(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord) DataReadQuery(org.eclipse.persistence.queries.DataReadQuery)

Aggregations

PLSQLrecord (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord)33 PLSQLStoredProcedureCall (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall)24 DataReadQuery (org.eclipse.persistence.queries.DataReadQuery)14 PLSQLCollection (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection)10 DataModifyQuery (org.eclipse.persistence.queries.DataModifyQuery)8 StringReader (java.io.StringReader)6 ObjectPersistenceWorkbenchXMLProject (org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject)6 XMLContext (org.eclipse.persistence.oxm.XMLContext)6 XMLMarshaller (org.eclipse.persistence.oxm.XMLMarshaller)6 Project (org.eclipse.persistence.sessions.Project)6 PLSQLrecordTestHelper.buildTestProject (org.eclipse.persistence.testing.tests.plsqlrecord.PLSQLrecordTestHelper.buildTestProject)6 PLSQLrecordTestHelper.buildWorkbenchXMLProject (org.eclipse.persistence.testing.tests.plsqlrecord.PLSQLrecordTestHelper.buildWorkbenchXMLProject)6 Test (org.junit.Test)6 Document (org.w3c.dom.Document)6 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)3 ComplexDatabaseType (org.eclipse.persistence.internal.helper.ComplexDatabaseType)2 OracleObjectType (org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType)2 PLSQLStoredFunctionCall (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredFunctionCall)2 PLSQLargument (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLargument)2 CompositeDatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.CompositeDatabaseType)2