use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class MySQLUnitDbAdapter method willDropTables.
@Override
public void willDropTables(Connection conn, DataMap map, Collection<String> tablesToDrop) throws Exception {
Procedure proc = map.getProcedure("cayenne_tst_select_proc");
if (proc != null && proc.getDataMap() == map) {
executeDDL(conn, "mysql", "drop-select-sp.sql");
executeDDL(conn, "mysql", "drop-update-sp.sql");
executeDDL(conn, "mysql", "drop-update-sp2.sql");
executeDDL(conn, "mysql", "drop-out-sp.sql");
}
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class SybaseUnitDbAdapter method createdTables.
@Override
public void createdTables(Connection con, DataMap map) throws Exception {
Procedure proc = map.getProcedure("cayenne_tst_select_proc");
if (proc != null && proc.getDataMap() == map) {
executeDDL(con, "sybase", "create-select-sp.sql");
executeDDL(con, "sybase", "create-update-sp.sql");
executeDDL(con, "sybase", "create-update-sp2.sql");
executeDDL(con, "sybase", "create-out-sp.sql");
}
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class ServerCaseDataDomainProvider method createAndInitDataDomain.
@Override
protected DataDomain createAndInitDataDomain() throws Exception {
DataDomain domain = super.createAndInitDataDomain();
DataNode node = null;
for (DataMap dataMap : domain.getDataMaps()) {
// add nodes and DataSources dynamically...
DataNodeDescriptor descriptor = new DataNodeDescriptor(dataMap.getName());
node = dataNodeFactory.createDataNode(descriptor);
node.addDataMap(dataMap);
// tweak procedures for testing...
for (Procedure proc : dataMap.getProcedures()) {
unitDbAdapter.tweakProcedure(proc);
}
// customizations from SimpleAccessStackAdapter that are not yet
// ported...
// those can be done better now
// node
// .getAdapter()
// .getExtendedTypes()
// .registerType(new StringET1ExtendedType());
//
domain.addNode(node);
}
if (domain.getDataMaps().size() == 1) {
domain.setDefaultNode(node);
}
return domain;
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class DataContextProcedureQueryIT method testSelect3.
@Test
public void testSelect3() throws Exception {
if (!accessStackAdapter.supportsStoredProcedures()) {
return;
}
// create an artist with painting in the database
createArtist(1000.0);
// test ProcedureQuery with Procedure as root
Procedure proc = context.getEntityResolver().getProcedure(SELECT_STORED_PROCEDURE);
ProcedureQuery q = new ProcedureQuery(proc);
q.addParameter("aName", "An Artist");
q.addParameter("paintingPrice", new Integer(3000));
List<?> artists = runProcedureSelect(q);
// check the results
assertNotNull("Null result from StoredProcedure.", artists);
assertEquals(1, artists.size());
DataRow artistRow = (DataRow) artists.get(0);
Artist a = context.objectFromDataRow(Artist.class, uppercaseConverter(artistRow));
Painting p = a.getPaintingArray().get(0);
// invalidate painting, it may have been updated in the proc
context.invalidateObjects(p);
assertEquals(2000, p.getEstimatedPrice().intValue());
}
use of org.apache.cayenne.map.Procedure in project cayenne by apache.
the class ProcedureTranslator method createSqlString.
/**
* Creates an SQL String for the stored procedure call.
*/
protected String createSqlString() {
Procedure procedure = getProcedure();
StringBuilder buf = new StringBuilder();
int totalParams = callParams.size();
// check if procedure returns values
if (procedure.isReturningValue()) {
totalParams--;
buf.append("{? = call ");
} else {
buf.append("{call ");
}
buf.append(procedure.getFullyQualifiedName());
if (totalParams > 0) {
// unroll the loop
buf.append("(?");
for (int i = 1; i < totalParams; i++) {
buf.append(", ?");
}
buf.append(")");
}
buf.append("}");
return buf.toString();
}
Aggregations