Buggy code:
protected static final String GET_MODIFIED_DATE = "getModifiedDate" ; protected static final String GET_COMMENTS = "getComments" ; protected static final String GET_URLS = "getUrls" ; protected static final String GET_EXISTING_ATTACHMENTS = "getExistingAttachments" ; protected static final String GET_ACTIVITY = "getActivity" ; protected static final String GET_CHILDREN = "getChildren" ; protected static final String GET_PARENTS = "getParents" ; protected static final String GET_ALL_DEPENDENCY_TYPES = "getAllDependencyTypes" ; protected static final String GET_DEPENDENCY = "getDependency" ; protected static final String GET_TEMPLATE_TYPES = "getTemplateTypes" ; protected static final String GET_TEMPLATEINFO = "getTemplateInfo" ; protected static final String GET_CLOSED_DATE = "getClosedDate" ; protected static final String GET_ORPHAN_ATTRIBUTEVALUES_LIST = "getOrphanAttributeValuesList" ; protected static final String GET_DEFAULT_TEXT_ATTRIBUTEVALUE = "getDefaultTextAttributeValue" ; protected static final String GET_DEFAULT_TEXT = "getDefaultText" ; Issue ( ) { } protected Issue ( Module module , IssueType issueType ) throws Exception { } public static Issue getNewInstance ( Module module , IssueType issueType ) throws Exception { } public String getUniqueId ( ) throws TorqueException { } public String getFederatedId ( ) throws TorqueException { } public void setFederatedId ( String id ) { } public static class FederatedId implements Serializable { String domainId ; String prefix ; int count ; public FederatedId ( String id ) { } public FederatedId ( String domain , String prefix , int count ) { } public void setUniqueId ( String id ) { } public String getDomain ( ) { } public String getPrefix ( ) { } public int getCount ( ) { } public void setDomain ( String domainId ) { } public void setPrefix ( String prefix ) { } public void setCount ( int count ) { } } public boolean isTemplate ( ) throws Exception { } public void addComment ( Attachment attachment , ScarabUser user ) throws Exception { } public void addFile ( Attachment attachment ) throws Exception { } public void removeFile ( String index ) throws Exception { } public ScarabModule getScarabModule ( ) { } public void setScarabModule ( ScarabModule module ) { } public void setModule ( Module me ) throws TorqueException { } public Module getModule ( ) throws TorqueException { } public static Issue getIssueById ( String id ) { } public static Issue getIssueById ( Issue . FederatedId fid ) { } public SequencedHashMap getModuleAttributeValuesMap ( ) throws Exception { } public AttributeValue getAttributeValue ( Attribute attribute ) throws Exception { } public List getAttributeValues ( Attribute attribute ) throws Exception { } public boolean isAttributeValue ( AttributeValue attVal ) throws Exception { } public AttributeValue [ ] getOrderedAttributeValues ( ) throws Exception { } private AttributeValue [ ] orderAttributeValues ( Map values , Attribute [ ] attributes ) throws Exception { } public HashMap getAttributeValuesMap ( ) throws Exception { } public HashMap getAllAttributeValuesMap ( ) throws Exception { } public boolean containsMinimumAttributeValues ( ) throws Exception { } public List getEligibleUsers ( Attribute attribute ) throws Exception { } public List getUsersToEmail ( String action ) throws Exception { } public List getAssociatedUsers ( ) throws Exception { } public List getUserAttributeValues ( ) throws Exception { } public Date getCreatedDate ( ) throws Exception { } public ScarabUser getCreatedBy ( ) throws Exception { } public Transaction getLastTransaction ( ) throws Exception { } public Date getModifiedDate ( ) throws Exception { } public ScarabUser getModifiedBy ( ) throws Exception { } public boolean isCommentsLong ( ) throws Exception { } private int getCommentsLimit ( ) throws Exception { } public List getComments ( boolean full ) throws Exception { List result = null ; Boolean fullBool = ( full ) ? Boolean . TRUE : Boolean . FALSE ; Object obj = getMethodResult ( ) . get ( this , Issue . GET_COMMENTS , fullBool ) ; if ( obj == null ) { <START_BUG> Criteria crit = new Criteria ( ) . add ( ISSUE_ID , getIssueId ( ) ) . addJoin ( ATTACHMENT_TYPE_ID , AttachmentPeer . ATTACHMENT_TYPE_ID ) . add ( ATTACHMENT_TYPE_ID , COMMENT__PK ) . addAscendingOrderByColumn ( CREATED_DATE ) ; <END_BUG> if ( ! full ) { crit . setLimit ( getCommentsLimit ( ) ) ; } result = AttachmentPeer . doSelect ( crit ) ; getMethodResult ( ) . put ( result , this , Issue . GET_COMMENTS , fullBool ) ; } else { result = ( ( List ) ( obj ) ) ; } return result ; } public List getUrls ( ) throws Exception { } public List getExistingAttachments ( ) throws Exception { } public int getHistoryLimit ( ) throws Exception { } public boolean isHistoryLong ( ) throws Exception { } public boolean isHistoryLong ( int limit ) throws Exception { } public List getActivity ( ) throws Exception { } public List getActivity ( int limit ) throws Exception { } public List getActivity ( boolean fullHistory ) throws Exception { } private List getActivity ( boolean fullHistory , int limit ) throws Exception { } public void addActivity ( Activity activity ) throws TorqueException { } public List getChildren ( ) throws Exception { } public List getParents ( ) throws Exception { } public List getAllDependencyTypes ( ) throws Exception { } public Depend getDependency ( Issue childIssue ) throws Exception { } public void save ( DBConnection dbCon ) throws TorqueException { } private int getNextIssueId ( DBConnection dbCon ) throws Exception { } private String getIdTableKey ( ) throws Exception { } private void saveIdTableKey ( DBConnection dbCon ) throws Exception { } public static List searchKeywords ( String [ ] keywords , boolean useAnd ) throws Exception { } public List getTemplateTypes ( ) throws Exception { } public IssueTemplateInfo getTemplateInfo ( ) throws Exception { } public Issue move ( Module newModule , String action , ScarabUser user ) throws Exception { } public Date getClosedDate ( ) throws Exception { } public void addVote ( ScarabUser user ) throws Exception , ScarabException { }

Fix:
Criteria crit = new Criteria ( ) . add ( ISSUE_ID , getIssueId ( ) ) . addJoin ( ATTACHMENT_TYPE_ID , AttachmentPeer . ATTACHMENT_TYPE_ID ) . add ( ATTACHMENT_TYPE_ID , COMMENT__PK ) . addDescendingOrderByColumn ( CREATED_DATE ) ;