From: <leg...@at...> - 2003-06-14 21:17:01
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-136 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-136 Summary: Criteria api appears to add elements to a SortedSet before setting their properties Type: Bug Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0 final Assignee: Reporter: Paul Rivers Created: Sat, 14 Jun 2003 4:16 PM Updated: Sat, 14 Jun 2003 4:16 PM Environment: Eclipse 2.1, Tomcat4.1.24, jdk1.4.1_03 Description: As I understand it, this query by criteria query: Criteria criteria = session.createCriteria(EntryDAO.class); criteria.setFirstResult(rangeStart); criteria.setMaxResults(rangeSize); criteria.addOrder(Order.desc("dateCreated")); entries = criteria.list(); Should return the same results as this one: Query query = session.createQuery("from EntryDAO order by dateCreated desc"); query.setFirstResult(rangeStart); query.setMaxResults(rangeSize); entries = query.list(); The problem is that the normal (second) query executes fine, but the Criteria (first) query throws a NullPointerException. Each entry has a SortedSet of Categories (It's specified in the mapping file). The stack trace for the null pointer exception leads to this line: result = this.getName().compareTo(otherCategory.getName()); In this function: public int compareTo(Object o) { int result; CategoryDAO otherCategory = (CategoryDAO) o; result = this.getDisplayIndex() - otherCategory.getDisplayIndex(); if(result == 0) { result = this.getName().compareTo(otherCategory.getName()); } return result; } The problem appears to be, to me, that for some reason the Criteria API 1. does the database query, 2. adds the new object to the SortedSet, 3. THEN sets it's properties, where it should be 1. doing the query 2. setting the properties, 3. then adding the category to the sortedset. PLEASE let me know if there's anything I can do to help with the issue, or if there's any other information you would like. Thanks. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |