Package org.apache.torque.criteria

Examples of org.apache.torque.criteria.Criteria


        multiRef.setOIntegerPk(oIntegerPk);
        multiRef.setPIntegerPk(pIntegerPk);
        multiRef.setNullableOIntegerFk(nullableOIntegerFk);
        multiRef.save();

        Criteria criteria = new Criteria().where(
                OIntegerPkPeer.ID,
                oIntegerPk.getId());
        List<MultiRef> list
            = MyMultiRefPeer.doSelectJoinAllExceptNullableOIntegerFk(
                    criteria);
View Full Code Here


    {
        fillTables();

        // check whether complex criteria are overwritten by
        // replaceBooleans
        Criteria criteria = new Criteria();
        Criterion criterion1 = new Criterion(
                BintBcharTypePeer.BCHAR_VALUE,
                Boolean.FALSE,
                Criteria.EQUAL);
        Criterion criterion2 = new Criterion(
                BintBcharTypePeer.BCHAR_VALUE,
                null,
                Criteria.ISNULL);
        criteria.where(criterion1.and(criterion2));
        List<BintBcharType> selectedList
                = BintBcharTypePeer.doSelect(criteria);
        // List should be empty, because and creates unfulfillable condition
        // If BasePeer.correctBooleans() replaces Criterion wrongly,
        // then we get entries in the list.
View Full Code Here

     */
    public void testBooleanSelectInChainedCriterionsUsingOr() throws Exception
    {
        fillTables();

        Criteria criteria = new Criteria();
        Criterion criterion1 = new Criterion(
                BintBcharTypePeer.BCHAR_VALUE,
                null,
                Criteria.ISNULL);
        Criterion criterion2 = new Criterion(
                BintBcharTypePeer.BCHAR_VALUE,
                Boolean.FALSE,
                Criteria.EQUAL);
        criteria.where(criterion1.or(criterion2));
        List<BintBcharType> selectedList
                = BintBcharTypePeer.doSelect(criteria);
        assertTrue("Should have read 1 dataset complex Criteria "
                + "but read " + selectedList.size(),
                selectedList.size() == 1);
View Full Code Here

     * @throws Exception if the test fails
     */
    public void testCorrectBooleansInUnqualifiedColumns() throws Exception
    {
        // check whether booleans are replaced with unqualified columns
        Criteria criteria = new Criteria()
            .where(new ColumnImpl("BINT_VALUE"), true)
            .and(new ColumnImpl("BCHAR_VALUE"), true);

        BintBcharTypePeer.correctBooleans(criteria);

        Criterion criterionInt
                = criteria.getTopLevelCriterion().getParts().get(0);
        Object intValue = criterionInt.getRValue();

        assertTrue("The boolean value should be an instance of Integer",
                intValue instanceof Integer);

        Criterion criterionChar
                = criteria.getTopLevelCriterion().getParts().get(1);
        Object charValue = criterionChar.getRValue();

        assertTrue("The boolean value should be an instance of String",
                charValue instanceof String);
    }
View Full Code Here

     *
     * @throws Exception if the test fails
     */
    public void testCorrectBooleansUnknownColumns() throws Exception
    {
        Criteria criteria = new Criteria()
            .where("BooleanCheck.bint_value", true)
            .and("BooleanCheck.bchar_value", true);

        BintBcharTypePeer.correctBooleans(criteria);

        Criterion criterionBool1
                = criteria.getTopLevelCriterion().getParts().get(0);
        Object boolValue1 = criterionBool1.getRValue();

        assertTrue("The boolean value should be an instance of Boolean",
               boolValue1 instanceof Boolean);

        Criterion criterionBool2
                = criteria.getTopLevelCriterion().getParts().get(1);
        Object boolValue2 = criterionBool2.getRValue();

        assertTrue("The boolean value should be an instance of Boolean",
               boolValue2 instanceof Boolean);
    }
View Full Code Here

     * Delete all previous data from the tested tables
     * and re-inserts test data.
     */
    private void fillTables() throws TorqueException
    {
        Criteria criteria = new Criteria();
        BintBcharTypePeer.doDelete(criteria);

        BintBcharType bc = new BintBcharType();
        bc.setId("t1");
        bc.setBintValue(true);
View Full Code Here

    public void setUp() throws Exception
    {
        super.setUp();

        // Clean up any previous failures
        Summarize1Peer.doDelete(new Criteria());

        // Create some test data
        for (int i = 0; i < INT_VALUES.length; i++)
        {
            Summarize1 rec = new Summarize1();
View Full Code Here

     *
     * @throws Exception if the test fails
     */
    public void testSelectAvg() throws Exception
    {
        Criteria criteria = new Criteria().addSelectColumn(
                new Avg(Summarize1Peer.INT_1));

        Integer avg = peer.doSelectSingleRecord(criteria);

        assertEquals(new Integer(2), avg);
View Full Code Here

     *
     * @throws Exception if the test fails
     */
    public void testSelectAvgDistinct() throws Exception
    {
        Criteria criteria = new Criteria().addSelectColumn(
                new Avg(Summarize1Peer.INT_1, true));

        Integer avg = peer.doSelectSingleRecord(criteria);

        assertEquals(new Integer(3), avg);
View Full Code Here

     *
     * @throws Exception if the test fails
     */
    public void testSelectCount() throws Exception
    {
        Criteria criteria = new Criteria().addSelectColumn(new Count("*"));

        Integer count = peer.doSelectSingleRecord(criteria);

        assertEquals(new Integer(4), count);
    }
View Full Code Here

TOP

Related Classes of org.apache.torque.criteria.Criteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.