In Hibernate 4 I've found (new for me) possibility to use XSD schema instead of DTD.
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
But the schema location is invalid and during initialization I've got error.
Does anybody knows what is wrong with XSD in Hibernate 4?
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping classpath://org/hibernate/hibernate-mapping-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" package="acme.foo.bar"/>
Try this, it should work better.
Schema location is just an identifier of the place, and this place can be bound to anywhere: internet, local drive. Particularly this schema (along with hibernate-configuration-4.0.xsd
) is placed inside the hibernate-core jar in the package org.hibernate. Since usually the schemaLocation and the actual location are the same, IDE will try to fetch it from where it points, but this is not our case.
You can configure your IDE to find this schema in this jar so that you can use autocomplete. If we're talking about IntelliJ, then go to the settings and configure your Schemas and DTDs to include the required schema.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With