Trying to get an external !ENTITY include to work with hbmxml files.

55 views
Skip to first unread message

Mark Mandel

unread,
Sep 14, 2010, 7:53:33 PM9/14/10
to cf-or...@googlegroups.com
So this is a bit of an interesting one.

Essentially what I'm trying to do is get implicit polymoprhism working,

but the core of the issue is that I cannot get this include to work in my hbmxml file.

A good example here:
https://forum.hibernate.org/viewtopic.php?f=1&t=998412&p=2415211#p2415211

I have the following (also attached test bed to email, if that will work) CFCs with hbmxml files:

Base.cfc
--------------------------------------------------------------------------------------
component mappedSuperClass="true"
{
    property name="id" type="numeric";
}

Base.hbmxml
--------------------------------------------------------------------------------------
<id name="id" type="int">
    <column name="id"/>
    <generator class="native"/>
</id>

User.cfc
--------------------------------------------------------------------------------------
component extends="Base" persistent="true"
{
    property name="name" type="string";
}

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
                                   [ <!ENTITY common SYSTEM "Base.hbmxml"> ]                                  
>
                                   
<hibernate-mapping>
    <class entity-name="User" lazy="true"
        name="cfc:mappedSuper.com.User" table="`User`">
        &common;
        <property name="name" type="string">
            <column name="name"/>
        </property>
    </class>
</hibernate-mapping>

In theory, this should work, and include the XML from Base.hbmxml into my User.hbmxml file, but it doesn't want to validate.  I get the following error:

Document root element "id", must match DOCTYPE root "null".                                                                                         
org.xml.sax.SAXParseException: Document root element "id", must match DOCTYPE root "null".
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.rootElementSpecified(Unknown Source)

Turning on DEBUG level logging I can see:

09/15 09:51:26 [jrpp-7] HIBERNATE DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
09/15 09:51:26 [jrpp-7] HIBERNATE DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
09/15 09:51:26 [jrpp-7] HIBERNATE DEBUG - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
09/15 09:51:26 [jrpp-7] HIBERNATE DEBUG - trying to resolve system-id [file:/mnt/hgfs/wwwroot/test/mappedSuper/com/Base.hbmxml]
09/15 09:51:26 Error [jrpp-7] - Document root element ""id"", must match DOCTYPE root ""null"". The specific sequence of files included or processed is: /mnt/hgfs/wwwroot/test/mappedSuper/index.cfm''

So it is resolving the include (which I can also see if mess around with it to get different errors), but for whatever reason, it doesn't think it's valid XML.

Anyone got any clever ideas? I'm at a loss.

Mark

--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

cf.Objective(ANZ) - Nov 18, 19 - Melbourne Australia
http://www.cfobjective.com.au

Hands-on ColdFusion ORM Training
www.ColdFusionOrmTraining.com
mappedSuper.zip

Mark Mandel

unread,
Sep 15, 2010, 9:52:01 PM9/15/10
to cf-or...@googlegroups.com
Thanks to Bob S's clever suggestion, I changed Base.hbmxml to Base.xml (and updated the !ENTITY defs), and it worked perfectly.

SupperMappedClass with hbmxml files :)

Mark
Reply all
Reply to author
Forward
0 new messages