[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-1665) Assert the class for a Criteria is mapped

Daniel Campagnoli (JIRA) noreply at atlassian.com
Wed Oct 17 02:35:39 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1665?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Campagnoli updated HHH-1665:
-----------------------------------

    Attachment: test case.zip

> Assert the class for a Criteria is mapped
> -----------------------------------------
>
>                 Key: HHH-1665
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1665
>             Project: Hibernate3
>          Issue Type: Improvement
>          Components: query-criteria
>    Affects Versions: 3.1.3
>            Reporter: Daniel Campagnoli
>            Priority: Minor
>         Attachments: test case.zip
>
>   Original Estimate: 5 minutes
>  Remaining Estimate: 5 minutes
>
> In SessionImpl it would be handy if when getting the results for a criteria query it checked to see if the class is mapped and failed fast, as it currently silently returns an empty list. I ran into this problem because we have multiple session factories with different class mapped and from one DAO i tried to query a class that wasnt mapped in the SessionFactory being used. Could also happen if you accidently put the wrong class or added the wrong import for a class.
> SessionImpl.java
> public List list(CriteriaImpl criteria) throws HibernateException {
> 		errorIfClosed();
> 		checkTransactionSynchStatus();
> 		String[] implementors = factory.getImplementors( criteria.getEntityOrClassName() );
> 		int size = implementors.length;
> +                                        if(size == 0)
> +                                           throw new HibernateException(criteria.getEntityOrClassName()  + " is not mapped");

-- 
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/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list