OK. I do a slight modification on my class and xml as follow :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="test.Quotation" table="QUOTATION">
<id name="id" column="QUOTATION_ID">
<generator class="native"/>
</id>
<composite-id>
<key-property name="name" column="NAME"/>
<key-property name="price" column="PRICE"/>
</composite-id>
</class>
</hibernate-mapping>
package test;
/**
*
* @author YC Cheok
*/
public class Quotation implements java.io.Serializable {
/** Creates a new instance of Quotation */
public Quotation() {
setName("noname");
setPrice(0.0);
}
public Quotation(String name, double price) {
setName(name);
setPrice(price);
}
public boolean equals(Object o) {
if(!(o instanceof Quotation))
return false;
Quotation quotation = (Quotation)o;
return this.price == quotation.price && this.name.equals(quotation.name);
}
public int hashCode() {
int result = 37;
final long tmp = Double.doubleToLongBits(price);
result = 37 * (int)(tmp ^ (tmp >>> 32));
result = 37 * result + name.hashCode();
return result;
}
private Long id;
private double price;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
However, I get the following error during run-time :
Code:
...
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
Any suggestion? Is there any wrong with my XML file?