Package org.apache.torque

Examples of org.apache.torque.ForeignKeySchemaData


     * @throws Exception if a database error occurs.
     */
    public void testDeleteByPrimaryKeyNoMatch() throws Exception
    {
        ForeignKeySchemaData.clearTablesInDatabase();
        ForeignKeySchemaData testData
                = ForeignKeySchemaData.getDefaultTestData();
        testData.save();

        NullableOIntegerFk toDelete
            = testData.getNullableOIntegerFkList().get(0);
        toDelete.setId(toDelete.getId() - 1);
        int preDeleteId = toDelete.getId();

        // check that four entries are in the NullableOIntegerFk table
        List<NullableOIntegerFk> nullableOIntegerFkList
View Full Code Here


     * @throws Exception if a database error occurs
     */
    public void testDeleteByCriteria() throws Exception
    {
        ForeignKeySchemaData.clearTablesInDatabase();
        ForeignKeySchemaData testData
                = ForeignKeySchemaData.getDefaultTestData();
        testData.save();

        // call delete method
        Criteria criteria = new Criteria();
        criteria.and(
                NullableOIntegerFkPeer.ID,
                testData.getNullableOIntegerFkList().get(1).getId(),
                Criteria.LESS_EQUAL);
        int deletedCount = NullableOIntegerFkPeer.doDelete(criteria);
        assertEquals(2, deletedCount);

        // check that only the last two entries remains
        // in the NullableOIntegerFk table
        List<NullableOIntegerFk> nullableOIntegerFkList
                = getNullableOIntegerFkList();
        assertEquals(2, nullableOIntegerFkList.size());
        assertEquals(
                testData.getNullableOIntegerFkList().get(2).getId(),
                nullableOIntegerFkList.get(0).getId());

        // check that no associated object has been deleted
        List<OIntegerPk> oIntegerPkList
                = OIntegerPkPeer.doSelect(new Criteria());
View Full Code Here

     * @throws Exception if a database error occurs
     */
    public void testDeleteByCriteriaNoMatch() throws Exception
    {
        ForeignKeySchemaData.clearTablesInDatabase();
        ForeignKeySchemaData testData
                = ForeignKeySchemaData.getDefaultTestData();
        testData.save();

        // call delete method
        Criteria criteria = new Criteria();
        criteria.and(NullableOIntegerFkPeer.NAME, "noMatch");
        int deletedCount = NullableOIntegerFkPeer.doDelete(criteria);
View Full Code Here

     * @throws Exception if a database error occurs
     */
    public void testDeleteWithOtherTableColumn() throws Exception
    {
        ForeignKeySchemaData.clearTablesInDatabase();
        ForeignKeySchemaData testData
                = ForeignKeySchemaData.getDefaultTestData();
        testData.save();

        // call delete method
        Criteria criteria = new Criteria();
        criteria.and(
                OIntegerPkPeer.ID,
                testData.getOIntegerPkList().get(0).getId());
        try
        {
            NullableOIntegerFkPeer.doDelete(criteria);
            fail("Exception should be thrown");
        }
View Full Code Here

     * @throws Exception if a database error occurs
     */
    public void testDeleteByCriteriaWithJoins() throws Exception
    {
        ForeignKeySchemaData.clearTablesInDatabase();
        ForeignKeySchemaData testData
                = ForeignKeySchemaData.getDefaultTestData();
        testData.save();

        // call delete method
        Criteria criteria = new Criteria();
        criteria.addJoin(
                NullableOIntegerFkPeer.FK,
                OIntegerPkPeer.ID,
                Criteria.INNER_JOIN);
        criteria.and(
                OIntegerPkPeer.ID,
                testData.getOIntegerPkList().get(0).getId());
        try
        {
            int deletedCount = NullableOIntegerFkPeer.doDelete(criteria);
            assertEquals(1, deletedCount);
        }
        catch (TorqueException e)
        {
            log.debug("Delete by joins does not work for this database.");
            return;
        }

        // check that the last two entries remains in the NullableOIntegerFk
        // table
        List<NullableOIntegerFk> nullableOIntegerFkList
                = getNullableOIntegerFkList();
        assertEquals(2, nullableOIntegerFkList.size());
        assertTrue(nullableOIntegerFkList.contains(
                testData.getNullableOIntegerFkList().get(1)));
        assertTrue(nullableOIntegerFkList.contains(
                testData.getNullableOIntegerFkList().get(2)));

        // check that no associated object has been deleted
        List<OIntegerPk> oIntegerPkList
                = OIntegerPkPeer.doSelect(new Criteria());
        assertEquals(3, oIntegerPkList.size());
View Full Code Here

TOP

Related Classes of org.apache.torque.ForeignKeySchemaData

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.