Search in sources :

Example 46 with DatabaseRecord

use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.

the class PLSQLrecordOutTestSet method runQuery.

@Test
public void runQuery() {
    DatabaseSession s = project.createDatabaseSession();
    s.dontLogMessages();
    s.login();
    OutputRowSessionEventAdapter outputParametersDetected = new OutputRowSessionEventAdapter();
    s.getEventManager().addListener(outputParametersDetected);
    boolean worked = false;
    String msg = null;
    Object result = null;
    Object outputRow = null;
    try {
        result = s.executeQuery("PLSQLrecordOut", PLSQLEmployeeType.class);
        worked = true;
        outputRow = outputParametersDetected.getEventResult();
    } catch (Exception e) {
        msg = e.getMessage();
    }
    assertTrue("invocation rec_test_out failed: " + msg, worked);
    assertNotNull("result is supposed to be not-null", result);
    DatabaseRecord record = (DatabaseRecord) outputRow;
    assertTrue("incorrect EMPNO", record.get("EMPNO").equals(new BigDecimal(1234)));
    assertTrue("incorrect ENAME", record.get("ENAME").equals("GOOFY"));
    assertTrue("incorrect JOB", record.get("JOB").equals("ACTOR"));
    assertNull("MGR is supposed to be null", record.get("MGR"));
    assertNull("HIREDATE is supposed to be null", record.get("HIREDATE"));
    assertTrue("incorrect SAL", record.get("SAL").equals(6000.0));
    assertNull("COMM is supposed to be null", record.get("COMM"));
    assertTrue("incorrect DEPTNO", record.get("DEPTNO").equals(new BigDecimal(20)));
    s.logout();
}
Also used : DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 47 with DatabaseRecord

use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.

the class joNijiNoTestSet method runQuery.

@SuppressWarnings("unchecked")
@Test
public void runQuery() {
    DatabaseSession s = project.createDatabaseSession();
    s.dontLogMessages();
    s.login();
    Object o = null;
    Vector queryArgs = new NonSynchronizedVector();
    queryArgs.add(100);
    queryArgs.add(101);
    boolean worked = false;
    String msg = null;
    try {
        o = s.executeQuery("joNijiNo", Empty.class, queryArgs);
        worked = true;
    } catch (Exception e) {
        msg = e.getMessage();
    }
    assertTrue("invocation joNijiNo failed: " + msg, worked);
    Vector results = (Vector) o;
    DatabaseRecord record = (DatabaseRecord) results.get(0);
    String y = (String) record.get("X");
    assertTrue("wrong y value", y.equals("test"));
    Integer aa = (Integer) record.get("AA");
    assertTrue("wrong aa value", aa == 1);
    s.logout();
}
Also used : DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) Vector(java.util.Vector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) Test(org.junit.Test)

Example 48 with DatabaseRecord

use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.

the class joNijijoTestSet method runQuery.

@SuppressWarnings("unchecked")
@Test
public void runQuery() {
    DatabaseSession s = project.createDatabaseSession();
    s.dontLogMessages();
    s.login();
    Object o = null;
    Vector queryArgs = new NonSynchronizedVector();
    queryArgs.add(100);
    queryArgs.add(101);
    boolean worked = false;
    String msg = null;
    try {
        o = s.executeQuery("joNijiNo", Empty.class, queryArgs);
        worked = true;
    } catch (Exception e) {
        msg = e.getMessage();
    }
    assertTrue("invocation joNijiNo failed: " + msg, worked);
    Vector results = (Vector) o;
    DatabaseRecord record = (DatabaseRecord) results.get(0);
    String y = (String) record.get("X");
    assertTrue("wrong y value", y.equals("test"));
    Integer aa = (Integer) record.get("AA");
    assertTrue("wrong aa value", aa == 1);
    s.logout();
}
Also used : DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) Vector(java.util.Vector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) Test(org.junit.Test)

Example 49 with DatabaseRecord

use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.

the class joNijioTestSet method runQuery.

@SuppressWarnings("unchecked")
@Test
public void runQuery() {
    DatabaseSession s = project.createDatabaseSession();
    s.dontLogMessages();
    s.login();
    Object o = null;
    Vector queryArgs = new NonSynchronizedVector();
    queryArgs.add(1);
    queryArgs.add("test");
    boolean worked = false;
    String msg = null;
    try {
        o = s.executeQuery("joNijio", Empty.class, queryArgs);
        worked = true;
    } catch (Exception e) {
        msg = e.getMessage();
    }
    assertTrue("invocation joNijio failed: " + msg, worked);
    Vector results = (Vector) o;
    DatabaseRecord record = (DatabaseRecord) results.get(0);
    BigDecimal x = (BigDecimal) record.get("X");
    assertTrue("wrong x value", x.intValue() == 51);
    String z = (String) record.get("Z");
    assertTrue("wrong z value", z.equals("test-thingie"));
    s.logout();
}
Also used : DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) Vector(java.util.Vector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 50 with DatabaseRecord

use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.

the class jiNioTestSet method runQuery.

@SuppressWarnings("unchecked")
@Test
public void runQuery() {
    DatabaseSession s = project.createDatabaseSession();
    s.dontLogMessages();
    s.login();
    Object o = null;
    Vector queryArgs = new NonSynchronizedVector();
    queryArgs.add("test");
    queryArgs.add(1);
    boolean worked = false;
    String msg = null;
    try {
        o = s.executeQuery("jiNio", Empty.class, queryArgs);
        worked = true;
    } catch (Exception e) {
        msg = e.getMessage();
    }
    assertTrue("invocation jiNio failed: " + msg, worked);
    Vector results = (Vector) o;
    DatabaseRecord record = (DatabaseRecord) results.get(0);
    Integer bool2int = (Integer) record.get("Y");
    assertTrue("wrong bool2int value", bool2int == 0);
    s.logout();
}
Also used : DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) Vector(java.util.Vector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) NonSynchronizedVector(org.eclipse.persistence.internal.helper.NonSynchronizedVector) Test(org.junit.Test)

Aggregations

DatabaseRecord (org.eclipse.persistence.sessions.DatabaseRecord)110 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)44 AbstractRecord (org.eclipse.persistence.internal.sessions.AbstractRecord)43 Vector (java.util.Vector)31 ArrayList (java.util.ArrayList)17 NonSynchronizedVector (org.eclipse.persistence.internal.helper.NonSynchronizedVector)17 BigDecimal (java.math.BigDecimal)14 List (java.util.List)14 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)14 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)14 Test (org.junit.Test)14 Expression (org.eclipse.persistence.expressions.Expression)12 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)12 HashMap (java.util.HashMap)11 Map (java.util.Map)10 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)7 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)7 RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)6 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)6 SQLUpdateStatement (org.eclipse.persistence.internal.expressions.SQLUpdateStatement)6