db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Fox (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TORQUE-200) Generate methods in Peer classes to retrieve a single object from a table
Date Fri, 11 May 2012 20:04:50 GMT

    [ https://issues.apache.org/jira/browse/TORQUE-200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13273563#comment-13273563
] 

Thomas Fox commented on TORQUE-200:
-----------------------------------

Not really. Criteria.setSingleRecord only makes sure that you get exactly one record, but
the return value of doSelect() is still a list
DoSelectSingleRecord makes sure you have 0 or 1 record and you get the object without any
list.
Of course both can be combined
                
> Generate methods in Peer classes to retrieve a single object from a table
> -------------------------------------------------------------------------
>
>                 Key: TORQUE-200
>                 URL: https://issues.apache.org/jira/browse/TORQUE-200
>             Project: Torque
>          Issue Type: Improvement
>          Components: Templates
>            Reporter: Thomas Fox
>            Assignee: Thomas Fox
>             Fix For: 4.0
>
>
> Often, one knows that a database query will return at most a single object.
> To get that object, the following code is needed:
> List<Book> bookList = BookPeer.doSelect(criteria);
> Book book = null;
> if (bookList.size > 1)
> {
>   throw new TooManyRowsException("...");
> }
> if (!bookList.isEmpty())
> {
>   book = bookList.get(0);
> }
> There should be methods named doSelectSingleRecord(...) generated in the Peer class which
contains teh above code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message