This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Taking DTD from Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Taking DTD from Classpath" Watch "Taking DTD from Classpath" New topic
Author

Taking DTD from Classpath

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
Hi guys

How can i make sure that my DTD hibernate-mapping-3.0.dtd is loaded from my local classpath or in other way from hibernate.jar. Inspite of pulling that one my the internet

Also i will be happy if some one explains me. what is the meaning of "-//Hibernate/Hibernate Mapping DTD 3.0//EN" in the DTD

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">


thanks
Amir
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I'm surprised that Hibernate doesn't already do that. But if it doesn't, here's what you need to do:

(1) Write an EntityResolver which returns an InputSource containing your local copy of the DTD when it's called. The documentation for EntityResolver has an example of how to do that.

(2) Persuade Hibernate's XML parser, the one which reads the XML configuration files, to use your EntityResolver. I just googled "hibernate entityresolver" and found e.g. this reference document which appears to tell you how to do that.
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
Iam using Hibernate with Spring. Any clues to add the custom Entityrolver via Spring configuration xml. If suppose iam using a Standalone java code i can register using

XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

thanks
Amir
 
 
subject: Taking DTD from Classpath