smg
smg

Reputation: 173

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?

Upvotes: 6

Views: 6747

Answers (2)

jontejj
jontejj

Reputation: 2860

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

Upvotes: 7

Stanislav Bashkyrtsev
Stanislav Bashkyrtsev

Reputation: 15316

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.

Upvotes: 2

Related Questions