XDoclet 2 Plugins
  1. XDoclet 2 Plugins
  2. XDP-211

Tag @hibernate.query with hibernate3 generates invalid xml (<query> as child of <class>)

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0.4
    • Fix Version/s: None
    • Component/s: hibernate
    • Labels:
      None
    • Environment:
      Windows XP + Maven2 + jdk1.4
    • Number of attachments :
      0

      Description

      I am using a @hibernate.query tag and the mapping task generates an invalid XXX.hdm.xml whith

      <hibernate-mapping>
      <class ...>
      ......
      <query .../>
      </class>

      when I try to create a hibernate sessionfactory I get: the following exception

      org.xml.sax.SAXParseException: Element "class" does not allow "query" here.

        Activity

        Hide
        Konstantin Pribluda added a comment -

        What hibernate version you are using? If you look into current DTD, you will see that
        that queries are allowed inside classs/subclass elements, and now they (names) are scoped...

        maybe an mergepoint will help you?
        ( if you provide a patch, I will can this really soon )

        Show
        Konstantin Pribluda added a comment - What hibernate version you are using? If you look into current DTD, you will see that that queries are allowed inside classs/subclass elements, and now they (names) are scoped... maybe an mergepoint will help you? ( if you provide a patch, I will can this really soon )
        Hide
        krico added a comment -

        I am using hibernate-3.0.5.

        My mapping is pointing to http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd

        The exception is beeing thrown by SaxParser

        Caused by: org.xml.sax.SAXParseException: Element "class" does not allow "query" here.
        at org.apache.crimson.parser.Parser2.error(Unknown Source)
        at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(Unknown Source)
        at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
        at org.apache.crimson.parser.Parser2.content(Unknown Source)
        at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
        at org.apache.crimson.parser.Parser2.content(Unknown Source)
        at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
        at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
        at org.apache.crimson.parser.Parser2.parse(Unknown Source)
        at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)

        Show
        krico added a comment - I am using hibernate-3.0.5. My mapping is pointing to http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd The exception is beeing thrown by SaxParser Caused by: org.xml.sax.SAXParseException: Element "class" does not allow "query" here. at org.apache.crimson.parser.Parser2.error(Unknown Source) at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(Unknown Source) at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source) at org.apache.crimson.parser.Parser2.content(Unknown Source) at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source) at org.apache.crimson.parser.Parser2.content(Unknown Source) at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source) at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source) at org.apache.crimson.parser.Parser2.parse(Unknown Source) at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source) at org.dom4j.io.SAXReader.read(SAXReader.java:465) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
        Hide
        Konstantin Pribluda added a comment -

        if you look at dtd under URL you will surely see that:

        <!ELEMENT class (
        meta*,
        subselect?,
        cache?,
        synchronize*,
        comment?,
        tuplizer*,
        (id|composite-id),
        discriminator?,
        natural-id?,
        (version|timestamp)?,
        (property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,
        ((join*,subclass*)|joined-subclass*|union-subclass*),
        loader?,sql-insert?,sql-update?,sql-delete?,
        filter*,
        resultset*,
        (query|sql-query)*
        )>

        so please blame Gavin & Those folks at RedHat who change DTD wiuthout notice....
        I just try to keep up with them. You may also want to upgrade HB to 3.2.1.ga which
        is source-compatible ( up to query names, which are qualified with class name now )

        Show
        Konstantin Pribluda added a comment - if you look at dtd under URL you will surely see that: <!ELEMENT class ( meta*, subselect?, cache?, synchronize*, comment?, tuplizer*, (id|composite-id), discriminator?, natural-id?, (version|timestamp)?, (property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*, ((join*,subclass*)|joined-subclass*|union-subclass*), loader?,sql-insert?,sql-update?,sql-delete?, filter*, resultset*, (query|sql-query)* )> so please blame Gavin & Those folks at RedHat who change DTD wiuthout notice.... I just try to keep up with them. You may also want to upgrade HB to 3.2.1.ga which is source-compatible ( up to query names, which are qualified with class name now )
        Hide
        krico added a comment -

        I just figured out what the problem is. On hibernate-3.0.5.jar the DTD doesn't allow <query /> under <class />

        I am not sure if this is a bug or not, but it certainly isn't a bug with xdoclet-plugin right?

        Show
        krico added a comment - I just figured out what the problem is. On hibernate-3.0.5.jar the DTD doesn't allow <query /> under <class /> I am not sure if this is a bug or not, but it certainly isn't a bug with xdoclet-plugin right?
        Hide
        Konstantin Pribluda added a comment -

        No this is not a bug, but this is a recent feature ( look into some recently fixed issues -
        there were patches for it ) It's also not a bug in hibernate - it's just irresponsible developers
        changing DTD without telling anybody...

        Show
        Konstantin Pribluda added a comment - No this is not a bug, but this is a recent feature ( look into some recently fixed issues - there were patches for it ) It's also not a bug in hibernate - it's just irresponsible developers changing DTD without telling anybody...
        Hide
        Wytze van der Ploeg added a comment -

        Shouldn't the query tag be placed outside the class tag?

        Like this:

        <hibernate-mapping>
        <class ...>
        ......
        </class>
        <query .../>
        </hibernate-mapping>

        Otherwise your query cannot be found when using session.getNamedQuery("queryName");

        Show
        Wytze van der Ploeg added a comment - Shouldn't the query tag be placed outside the class tag? Like this: <hibernate-mapping> <class ...> ...... </class> <query .../> </hibernate-mapping> Otherwise your query cannot be found when using session.getNamedQuery("queryName");
        Hide
        Konstantin Pribluda added a comment -

        in this case you should prepend classname to it - yet another lovely feature of hibernate...

        Show
        Konstantin Pribluda added a comment - in this case you should prepend classname to it - yet another lovely feature of hibernate...
        Hide
        Konstantin Pribluda added a comment -

        This is not an issue but change in hibernate behaviour

        Show
        Konstantin Pribluda added a comment - This is not an issue but change in hibernate behaviour

          People

          • Assignee:
            Unassigned
            Reporter:
            krico
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: