Search code examples
hibernatehibernate-mappinghibernate-4.x

New XSD schema in Hibernate 4


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?


Solution

  • 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.