Example usage for javax.persistence ParameterMode OUT

List of usage examples for javax.persistence ParameterMode OUT

Introduction

In this page you can find the example usage for javax.persistence ParameterMode OUT.

Prototype

ParameterMode OUT

To view the source code for javax.persistence ParameterMode OUT.

Click Source Link

Document

Stored procedure output parameter

Usage

From source file:example.springdata.jpa.storedprocedures.UserRepositoryIntegrationTests.java

@Test
public void plainJpa21() {

    StoredProcedureQuery proc = em.createStoredProcedureQuery("plus1inout");
    proc.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN);
    proc.registerStoredProcedureParameter(2, Integer.class, ParameterMode.OUT);

    proc.setParameter(1, 1);//  www  . ja  va 2 s.  com
    proc.execute();

    assertThat(proc.getOutputParameterValue(2), is((Object) 2));
}

From source file:tools.xor.logic.DefaultStoredProcedure.java

private StoredProcedure getCreateSP() {
    StoredProcedure sp = new StoredProcedure();
    sp.setName("basicInfoCreate");
    sp.setAction(AggregateAction.CREATE);

    // id//from  www.j  a  v a2 s.  co m
    ParameterMapping pm = new ParameterMapping();
    pm.setAttribute("id");
    pm.setMode(ParameterMode.OUT);

    List<ParameterMapping> pmList = new ArrayList<ParameterMapping>();
    pmList.add(pm);
    sp.setParameterList(pmList);

    // name
    pm = new ParameterMapping();
    pm.setAttribute("name");
    pmList.add(pm);

    // displayName
    pm = new ParameterMapping();
    pm.setAttribute("displayName");
    pmList.add(pm);

    // description
    pm = new ParameterMapping();
    pm.setAttribute("description");
    pmList.add(pm);

    // iconUrl
    pm = new ParameterMapping();
    pm.setAttribute("iconUrl");
    pmList.add(pm);

    // detailedDescription
    pm = new ParameterMapping();
    pm.setAttribute("detailedDescription");
    pmList.add(pm);

    // extra1
    pm = new ParameterMapping();
    pm.setName("extra1");
    pm.setType(String.class);
    pm.setDefaultValue("ABC");
    pm.setMode(ParameterMode.IN);
    pmList.add(pm);

    // extra2
    pm = new ParameterMapping();
    pm.setName("extra2");
    pm.setType(Date.class);
    pm.setDefaultValue("2013-10-21T13:28:06.419Z");
    pm.setMode(ParameterMode.OUT);
    pmList.add(pm);

    // extra2
    pm = new ParameterMapping();
    pm.setName("extra3");
    pm.setType(void.class);
    pm.setMode(ParameterMode.OUT);
    pmList.add(pm);

    return sp;
}