- This topic has 8 replies, 2 voices, and was last updated 19 years, 8 months ago by
Riyad Kalla.
-
AuthorPosts
-
ripetersenMemberI just installed MyEclipse, now when I open an existing project I get a bunch of errors on my hibernate mapping files:
Attribute “index” must be declared for element type “property”
Here is an example of the line it is complaining about:<property name="skuNumber" column="sku_number" not-null="true" index="sku_number_ndx"/>
This is Hibernate 2 – I checked the DTD
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
and “index” is a valid attribute for the property element. Any ideas on why this is generating an error / how to make it stop?
Thanks.
Riyad KallaMemberCan you paste the entire file so we can validate it here and see what is going on? Also, how was the hbm.xml file generated?
ripetersenMemberHere is the entire .hbm.xml file. It was hand coded.
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping package="com.orangefood.commerce.catalog"> <class name="SkuImpl" table="sku"> <cache usage="read-write"/> <id name="id" column="sku_id"> <generator class="native"/> </id> <version name="version" /> <property name="name" not-null="true"/> <property name="skuNumber" column="sku_number" not-null="true" index="sku_number_ndx"/> <property name="startDate" column="start_date"/> <property name="endDate" column="end_date"/> <property name="listPrice" column="list_price" not-null="true"/> <property name="salePrice" column="sale_price" not-null="true"/> <property name="onSale" column="on_sale" not-null="true"/> <many-to-one name="productAssignment" column="product_id" foreign-key="prod_sku_fk"/> <set name="productSkuRelationships" lazy="true" inverse="true" cascade="all-delete-orphan"> <cache usage="read-write"/> <key column="sku_id" foreign-key="prod_rel_sku_fk" /> <one-to-many class="ProductSkuRelationship"/> </set> <set name="textSet" table="sku_text" lazy="true" cascade="all"> <cache usage="read-write"/> <key column="sku_id" foreign-key="text_sku_fk"/> <composite-element class="com.orangefood.java.i18n.LocalizedContentImpl"> <property name="name"/> <property name="content" length="4000"/> <property name="locale"/> </composite-element> </set> <set name="mediaSet" table="sku_media" lazy="true" cascade="all"> <cache usage="read-write"/> <key column="sku_id" foreign-key="media_sku_fk"/> <composite-element class="com.orangefood.java.i18n.LocalizedContentImpl"> <property name="name"/> <property name="content" length="1000"/> <property name="locale"/> </composite-element> </set> </class> </hibernate-mapping>
Riyad KallaMemberI double checked the Hibernate DTD and there is no “index” attribute for the “property” tag, if this did used to validate, my guess is that you might have had XML validation turned off.
ripetersenMemberWhen I look at the DTD from http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd
I see<!-- Property of an entity class or component, component-element, composite-id, etc. JavaBeans style properties are mapped to table columns. --> <!ELEMENT property (meta*,column*)> <!ATTLIST property name CDATA #REQUIRED> <!ATTLIST property access CDATA #IMPLIED> <!ATTLIST property type CDATA #IMPLIED> <!ATTLIST property column CDATA #IMPLIED> <!ATTLIST property length CDATA #IMPLIED> <!ATTLIST property not-null (true|false) "false"> <!ATTLIST property unique (true|false) "false"> <!ATTLIST property update (true|false) "true"> <!-- only supported for properties of a class (not component) --> <!ATTLIST property insert (true|false) "true"> <!-- only supported for properties of a class (not component) --> <!ATTLIST property formula CDATA #IMPLIED> <!-- only supported for properties of a class (not component) --> <!ATTLIST property index CDATA #IMPLIED> <!-- include the columns spanned by this property in an index -->
which does have an ‘index’ attribute for the property element, no?
Riyad KallaMemberHmm, our XML catalog (what is being used to validate your file) has a hibernate-mapping-2.0.dtd with the following entry:
<!ELEMENT property (meta*,column*)> <!ATTLIST property name CDATA #REQUIRED> <!ATTLIST property access CDATA #IMPLIED> <!ATTLIST property type CDATA #IMPLIED> <!ATTLIST property column CDATA #IMPLIED> <!ATTLIST property length CDATA #IMPLIED> <!ATTLIST property not-null (true|false) "false"> <!ATTLIST property unique (true|false) "false"> <!ATTLIST property update (true|false) "true"> <!-- only supported for properties of a class (not component) --> <!ATTLIST property insert (true|false) "true"> <!-- only supported for properties of a class (not component) --> <!ATTLIST property formula CDATA #IMPLIED> <!-- only supported for properties of a class (not component) -->
note the lack of the index… but the remote one magically has it… I’ll file this bug so we can upgrade this DTD. Sorry for the trouble, not sure what happened here.
ripetersenMemberThanks. So in the mean time can is there a way I can replace the DTD in the XML Catalog with the remote one?
ripetersenMemberActually I think I figured it out. I replaced /eclipse/plugins/com.ibm.webtooling.system.dtds_14.0.0/dtds/hibernate-mapping-2.0.dtd from below the install directory with the remote version and it appears to work (restart of Eclipse required).
Riyad KallaMemberWe’ve got this fix targetted for 4.0.1 release about 6 weeks off, in the mean time your workaround is exactly right, thank you for following up so others in the same position can learn from this thread.
-
AuthorPosts