From: Mike D. (JIRA) <no...@at...> - 2006-05-02 17:04:27
|
AbstractEntityPersister causes an exception when a row in a joined table is missing with fetch="select" ------------------------------------------------------------------------------------------------------- Key: HHH-1713 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1713 Project: Hibernate3 Type: Bug Components: core Versions: 3.1.3, 3.2.0 cr1 Environment: Hibernate 3.1.3, 3.2.0cr1 Oracle 9i (using odjbc14.jar from Oracle 10.1.0.4) Reporter: Mike Dillon Priority: Minor Attachments: AbstractEntityPersister.java.patch When using the <join> mapping, the behavior of AbstractEntityPersister when the joined row is missing is not consistent between fetch="join" and fetch="select". When fetch="join" and the row is missing, the AbstractEntityPersister simply sets all the outer joined fields to null since that's what comes back from the database. However, when fetch="select" and the row is missing, an SQLException is thrown. The reason is that the call to ResultSet.next() is not checked to see if a row is available before calling ResultSet.getXXXX(). In our Oracle enviroment, this resulted in a cryptic JDBC error about an "Exhausted Resultset". The fix is to check the return value of ResultSet.next(). I have attached a patch with a proposed fix for this issue. To be consistent with the current behavior of fetch="join", it explicitly sets all fields that come from the "sequential select" to null when the select does not produce any rows. This contradicts the hibernate-mapping DTD which says that the "optional" attribute on <join> defaults to false, but since that attribute is undocumented and the current implementation doesn't seem to respect this attribute even when fetch="join", I decided to be consistent with the actual semantics of fetch="join". The behavior of the optional attibute probably needs to be fixed in both cases, but I didn't address that with my patch. It seems that optional only works as advertised when Hibernate is able to produce a query with a single polymorphic join and can use an inner join instead of a left outer join. My patch was created against Hibernate 3.1.3, but I looked at the same code in 3.2.0cr1 and it has not changed. -- 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 |