6

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?

informatik01
  • 16,038
  • 10
  • 74
  • 104
smg
  • 173
  • 1
  • 8
  • If you want, here is a working (as of now) location of the XML Schema Definition file for the Hibernate configuration files: **http://hibernate.org/xsd/hibernate-configuration/hibernate-configuration-4.0.xsd** You can use it inside `xsi:schemaLocation` attribute. The following page has links to available XSD files for Hibernate (currently there is only _one_ XSD there): http://hibernate.org/xsd/hibernate-configuration/. – informatik01 Nov 13 '16 at 21:27
  • @informatik01 I think you meant https://hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd instead. – Daniel Beer May 26 '20 at 08:00
  • @DanielBeer Ah, [yes,](http://hibernate.org/xsd/hibernate-mapping/) you're right. Danke ) – informatik01 May 26 '20 at 10:01

2 Answers2

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

George
  • 769
  • 4
  • 11
  • 31
jontejj
  • 2,800
  • 1
  • 25
  • 27
2

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.

Stanislav Bashkyrtsev
  • 14,470
  • 7
  • 42
  • 45
  • Thanks, but currently there are a lot of issues that trigger usage of xsd schema. Hibernate Dev Team will fix part of them with next major release 5.0.0, so for now migration to this xsd not achievable. – smg Jan 22 '13 at 21:43