Package org.apache.torque.criteria

Examples of org.apache.torque.criteria.Criteria


     *
     * @throws Exception if the test fails
     */
    public void testSelectSingleRecordResultNull() throws Exception
    {
        Criteria criteria = new Criteria().where(
                AuthorPeer.AUTHOR_ID,
                -1);

        Author author = AuthorPeer.doSelectSingleRecord(criteria);
        assertEquals(null, author);
View Full Code Here


     *
     * @throws Exception if the test fails
     */
    public void testSelectSingleRecordTooManyRecords() throws Exception
    {
        Criteria criteria = new Criteria();

        try
        {
            AuthorPeer.doSelectSingleRecord(criteria);
            fail("Exception expected");
View Full Code Here

     *
     * @throws Exception if the test fails.
     */
    public void testSelectOperatorIsNull() throws Exception
    {
        Criteria criteria = new Criteria();
        criteria.where(BookPeer.ISBN, null, Criteria.ISNULL);

        List<Book> books = BookPeer.doSelect(criteria);
        assertEquals(10, books.size());
    }
View Full Code Here

     *
     * @throws Exception if the test fails.
     */
    public void testSelectOperatorIsNullOtherComparison() throws Exception
    {
        Criteria criteria = new Criteria();
        criteria.where(BookPeer.ISBN, "xy", Criteria.ISNULL);

        List<Book> books = BookPeer.doSelect(criteria);
        assertEquals(10, books.size());
    }
View Full Code Here

     *
     * @throws Exception if the test fails.
     */
    public void testSelectOperatorIsNotNull() throws Exception
    {
        Criteria criteria = new Criteria();
        criteria.where(BookPeer.ISBN, null, Criteria.ISNOTNULL);

        List<Book> books = BookPeer.doSelect(criteria);
        assertEquals(90, books.size());
    }
View Full Code Here

     *
     * @throws Exception if the test fails.
     */
    public void testSelectOperatorIsNotNullOtherComparison() throws Exception
    {
        Criteria criteria = new Criteria();
        criteria.where(BookPeer.ISBN, "xy", Criteria.ISNOTNULL);

        List<Book> books = BookPeer.doSelect(criteria);
        assertEquals(90, books.size());
    }
View Full Code Here

     * @throws Exception if the test fails.
     */
    public void testPartialSelectOnlyOwnColumns() throws Exception
    {
        Book bookToSelect = authorList.get(0).getBooks().get(0);
        Criteria criteria = new Criteria()
            .where(BookPeer.BOOK_ID, bookToSelect.getBookId())
            .addSelectColumn(BookPeer.BOOK_ID)
            .addSelectColumn(BookPeer.TITLE);

        List<Book> books = BookPeer.doSelect(criteria);
View Full Code Here

     *
     * @throws Exception if the test fails.
     */
    public void testPartialSelectOffset() throws Exception
    {
        Criteria criteria = new Criteria();
        Book bookToSelect = authorList.get(0).getBooks().get(0);
        criteria.where(BookPeer.BOOK_ID, bookToSelect.getBookId());
        criteria.addSelectColumn(BookPeer.BOOK_ID);
        criteria.addSelectColumn(BookPeer.TITLE);
        // use CompositeMapper to enforce offset
        CompositeMapper recordMapper = new CompositeMapper();
        recordMapper.addMapper(new BookRecordMapper(), 1);

        List<List<Object>> books = BookPeer.doSelect(criteria, recordMapper);
View Full Code Here

     *
     * @throws Exception if the test fails.
     */
    public void testPartialSelectForeignColumns() throws Exception
    {
        Criteria criteria = new Criteria();
        Book bookToSelect = authorList.get(0).getBooks().get(0);
        criteria.where(BookPeer.BOOK_ID, bookToSelect.getBookId());
        criteria.addSelectColumn(AuthorPeer.AUTHOR_ID);
        criteria.addSelectColumn(BookPeer.BOOK_ID);
        criteria.addSelectColumn(AuthorPeer.NAME);
        criteria.addSelectColumn(BookPeer.TITLE);
        criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID);

        List<Book> books = BookPeer.doSelect(criteria);
        assertEquals(1, books.size());
        Book selectedBook = books.get(0);
        assertEquals(bookToSelect.getBookId(), selectedBook.getBookId());
View Full Code Here

     * @throws Exception if the test fails.
     */
    public void testPartialSelectNoOwnColumns() throws Exception
    {
        Book bookToSelect = authorList.get(0).getBooks().get(0);
        Criteria criteria = new Criteria()
                .where(BookPeer.BOOK_ID, bookToSelect.getBookId())
                .addSelectColumn(BookPeer.BOOK_ID);

        List<Author> authors = BookPeer.doSelect(
                criteria, new AuthorRecordMapper());
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.