When we build the hibernate application which can be web or console aplication that have to check in the first attempt to resolve the DTD in its classpath. Fist it register a custom org.xml.sax.EntityResolver implementation with the SAXReader. This is used to read the xml files. This custom EntityResolver recognizes two different systemId namespaces which are given below:
1. Hibernate namespace is recoginzed whenever the resolver encouters a systemId starting with http://hibernate.sourceforge.net/. The resolver attempts to resolve these entities via the classloader which loaded the Hibernate class.
2. user namespace is recognized whenever the resolver encounters a systemId using a classpath://URL protocol. The resolver will attempt to resolve these entities via (1) the current thread context classloader and (2) the classloader which loaded Hibernate classes.
Which can be understand by the following code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<!ENTITY types SYSTEM "classpath://your/domain/types.xml">
<id name="id" type="my-custom-id-type">
Where types.xml is a resource in the your.domain package and contains a custom typedef.