[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2488) Resolution of filters' conditions should be postponed till all mappings are loaded.

Dmitry Katsubo (JIRA) noreply at atlassian.com
Tue Mar 13 04:37:08 EDT 2007


Resolution of filters' conditions should be postponed till all mappings are loaded.
-----------------------------------------------------------------------------------

         Key: HHH-2488
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2488
     Project: Hibernate3
        Type: Bug

  Components: core  
    Versions: 3.2.2    
 Environment: Hibernate-Version: 3.2.2.ga
Java(TM) SE Runtime Environment (build 1.6.0-b105)
    Reporter: Dmitry Katsubo


When trying to use the possibility to define the conditions for the same filters in {{<filter-def>}}, the following exception occurs, as the resolution of conditions should be done at a later stage, after all mappings are loaded:

{noformat}
Exception in thread "main" java.lang.NullPointerException
	at org.hibernate.cfg.HbmBinder.parseFilter(HbmBinder.java:2931)
	at org.hibernate.cfg.HbmBinder.bindCollection(HbmBinder.java:1462)
	at org.hibernate.cfg.HbmBinder$2.create(HbmBinder.java:2757)
{noformat}

The example of definition, that uses filters:
{code:xml|title=clauses.hbm.xml|borderStyle=solid}
	<class name="ClauseFolderImpl" table="stc_folders">
		<id name="id">
			<generator class="native" />
		</id>

		<property name="name" not-null="true" />
		<property name="private" not-null="true" />

		<set name="subFolders" outer-join="false" cascade="none">
			<key column="parentId" />
			<one-to-many class="ClauseFolderImpl" />

			<filter name="folderFilterLimited" />
			<filter name="folderFilter" />
		</set>
		
		<filter name="folderFilterLimited" />
		<filter name="folderFilter" />
	</class>

	<filter-def name="folderFilterLimited" condition="(parentId is null or (languageId = :languageId and procedureTypeId = :procedureTypeId))" >
		<filter-param name="languageId" type="int" />
		<filter-param name="procedureTypeId" type="int" />
	</filter-def>
	<filter-def name="folderFilter" condition="(parentId is null or private = :isPrivate)">
		<filter-param name="isPrivate" type="boolean" />
	</filter-def>
{code}

As Hibernate ues DTD to check the validity of configuration file, the {{<filter-def>}} definitions can't be moved to the beginning of the configuration file. The possible walkaround is to define filters in another file, and include it first:
{code:xml|title=hibernate-configuration.xml|borderStyle=solid}
<hibernate-configuration>
    <session-factory>
...
        <mapping resource="filters.hbm.xml"/> <!-- only filter-def's here -->
        <mapping resource="clauses.hbm.xml"/>
...
    </session-factory>
</hibernate-configuration>

{code}

Relative issue is [http://opensource.atlassian.com/projects/hibernate/browse/HHH-1182#action_21052 HHH-1182].

-- 
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