-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Query File Config and Generated Code
PostPosted: Fri Oct 10, 2003 11:10 am 
Newbie

Joined: Thu Oct 09, 2003 9:02 am
Posts: 4
Location: New York, NY USA
Howdy,

I'd like to store my queries in a file separate from the class/table *.hbm.xml mappings so they don't get clobbered everytime a I run Middlegen against my schema?

I realize that this is more of an XML issue (elements must start and end w/in the same entity) and/or Middlegen issue, but I'm wondering if this has already been encountered and solved by a good samaritan in the Hibernate communtiy.

Any pointers are much appreciated...

Thanks!

Matt

BTW - Hibernate rocks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2003 11:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Why don't you just have them in seperate hbm.xml file(s) ?

The definition is

<!ELEMENT hibernate-mapping (meta*, import*, class*, query*)>

so, that is possible.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2003 11:57 am 
Newbie

Joined: Thu Oct 09, 2003 9:02 am
Posts: 4
Location: New York, NY USA
Yeah, I tried this in hibernate.cfg.xml:


Code:
<hibernate-configuration>

    <session-factory>
        ...
        <property name="show_sql">true</property>       
        ...
        <mapping resource="example/MyClass.hbm.xml"/>
        ...
        <mapping resource="query.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


and this in query.cfg.xml:

Code:
<hibernate-mapping>

<query name="example.MyClass.select.all">
    from example.MyClass as myClass
</query>

</hibernate-mapping>



But the XML parser complains:

Code:
org.dom4j.DocumentException: Error on line 65 of document  : XML document structures must start and end within the same entity. Nested exception: XML document structures must start and end within the same entity.
   at org.dom4j.io.SAXReader.read(SAXReader.java:355)
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
   at com.abp.nl.fi.SimpleTest.initHibernate(SimpleTest.java:192)
   at com.abp.nl.fi.SimpleTest.<init>(SimpleTest.java:29)
   at com.abp.nl.fi.SimpleTest.main(SimpleTest.java:34)
Nested exception:
org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:339)
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
   at com.abp.nl.fi.SimpleTest.initHibernate(SimpleTest.java:192)
   at com.abp.nl.fi.SimpleTest.<init>(SimpleTest.java:29)
   at com.abp.nl.fi.SimpleTest.main(SimpleTest.java:34)
rethrown as net.sf.hibernate.MappingException: Error on line 65 of document  : XML document structures must start and end within the same entity. Nested exception: XML document structures must start and end within the same entity.
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:260)
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
   at com.abp.nl.fi.SimpleTest.initHibernate(SimpleTest.java:192)
   at com.abp.nl.fi.SimpleTest.<init>(SimpleTest.java:29)
   at com.abp.nl.fi.SimpleTest.main(SimpleTest.java:34)
Caused by: org.dom4j.DocumentException: Error on line 65 of document  : XML document structures must start and end within the same entity. Nested exception: XML document structures must start and end within the same entity.
   at org.dom4j.io.SAXReader.read(SAXReader.java:355)
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
   ... 8 more
Exception in thread "main"


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 11, 2003 6:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh ? that's sounds like a mistype somewhere!

I can see one: query.hbm.xml in the code, but query.cfg.xml in the text ? error ?

What happen if you just add query.hbm.xml via code instead ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 11, 2003 7:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I suppose I can add this option to the enhancement list of Middlegen.


Top
 Profile  
 
 Post subject: Query File Config and Generated Code
PostPosted: Mon Oct 13, 2003 10:07 am 
Newbie

Joined: Thu Oct 09, 2003 9:02 am
Posts: 4
Location: New York, NY USA
Max,

The typo was actually just in my post and the file is located correctly. The error occurs as the file's being parsed.

David,

I would offer to help, but ATM my newbie-ness to Hibernate/Middlegen and a lack of time, combine to make me somewhat useless; although, I'm glad to give it a shot...

Thanks, everyone, for your help!

Matt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.