[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1665) Assert the class for a Criteria is mapped
Baptiste MATHUS (JIRA)
noreply at atlassian.com
Fri Apr 13 06:03:04 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_26709 ]
Baptiste MATHUS commented on HHH-1665:
--------------------------------------
Completely agree with this report.
I just can't imagine the Hibernate team is not aware of this behaviour and that it was not made on purpose: isn't it to be able to handle polymorphism?
In fact, it's always very surprising when Hibernate doesn't say anything when you're actually trying to query a non mapped class, so it doesn't know which table to hit...
If made on purpose, I guess it'd be a good idea to document this a bit further and why it couldn't throw an exception, or at least issue a log.warn()...
Thanks a lot.
> 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
> 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