[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-1107) <jdbcconfiguration> tag does not support the <mapping> tags defined in the hibernate.cfg.xml

Julien Kronegg (JIRA) noreply at atlassian.com
Wed Jan 28 03:50:39 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-1107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32206#action_32206 ] 

Julien Kronegg commented on HBX-1107:
-------------------------------------

Hibernate Tools Reference Guide, Section 4.4.4 on configuration exporter (http://www.hibernate.org/hib_docs/tools/reference/en/html_single/#d0e1244) also intends to generate hibernate.cfg.xml file with <mapping class|resource> for <jdbcconfiguration> (which are ignored as seen above).

It should also be noted that it is not possible to map annotated classes because in the second solution above (Ant fileset), only .hbm.xml files are allowed.

So IMHO, the most efficient bug correction would be to add an attribute ignoreconfigxmlmapppings="false|true" in the <jdbcconfiguration> which gives access to the private field org.hibernate.cfg.JDBCMetaDataConfiguration.ignoreconfigxmlmapppings. This attribute should be defaulted to false to allow reading the mappings from the hibernate.cfg.xml. In such case, only the reference guide's jdbcconfiguration section (4.3.4) need to be updated.

> <jdbcconfiguration> tag does not support the <mapping> tags defined in the hibernate.cfg.xml
> --------------------------------------------------------------------------------------------
>
>                 Key: HBX-1107
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1107
>             Project: Hibernate Tools
>          Issue Type: Bug
>          Components: ant
>    Affects Versions: 3.2beta10
>         Environment: JDK 1.5.0 (IBM J9 VM 2.3)
>            Reporter: Julien Kronegg
>            Priority: Minor
>
> Hibernate Tools documentation states that Ant tasks can be configured using JDBC configuration (http://www.hibernate.org/hib_docs/tools/reference/en/html_single/#d0e1053). Specifying already existing mappings is allowed by two means:
> 1) in the hibernate.cfg.xml
> 2) in a Ant fileset as a child of the <jdbcconfiguration> tag
> The parent <configuration> tag documentation states that a standard Ant fileset can be inserted to include hibernate mapping files and prevent from duplicating mappings in hibernate.cfg.xml:	
>   "A standard Ant fileset. Used to include hibernate mapping files.Remember that if mappings are already specified in the hibernate.cfg.xml then it should not be included via the fileset as it will result in duplicate import exceptions."
> This suggests that both mapping are valid.
> The problem is:
> When specifying a <jdbcconfiguration .. configurationfile="hibernate.cfg.xml"> the <mapping> tags defined in the hibernate.cfg.xml are ignored (however, using the "fileset" solution works).
> This problem comes from the org.hibernate.cfg.JDBCMetaDataConfiguration class: the parseMappingElement(Element,String) method does not allow parsing mapping elements because ignoreconfigxmlmapppings is set to true.
> In this case, hibernate tools logs the following message:
>   [hibernatetool] Oct 7, 2008 9:18:27 AM org.hibernate.cfg.JDBCMetaDataConfiguration parseMappingElement
>   [hibernatetool] INFO: Ignoring null mapping
> The message "Ignoring null mapping" (where null is the <session-factory> name property) is not very useful. 
> Things to be corrected:
> 1) in org.hibernate.cfg.JDBCMetaDataConfiguration, the log message 
>   log.info("Ignoring "+name+" mapping");
> should be replaced by
>   log.info("Ignoring session-factory "+(name!=null?name+" ":"")+"mapping: "+subelement.asXML()+" (jdbcconfiguration tags does not support mapping in the hibernate.cfg.xml file. Please use ant fileset instead)");
> 2) the JDBC configuration documentation should state that mappings in the hibernate.cfg.xml file are ignored.

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