Hello, all!
problem:
+-----------------------------------------------------------------------------+
%tomcat_home%\logs\stdout_20090311.log:
+-----------------------------------------------------------------------------+
14:27:35,406 INFO Environment:520 - Hibernate 3.3.0.CR1
14:27:35,406 INFO Environment:553 - hibernate.properties not found
14:27:35,406 INFO Environment:687 - Bytecode provider name : cglib
14:27:35,421 INFO Environment:604 - using JDK 1.4 java.sql.Timestamp handling
14:27:35,500 INFO Configuration:1437 - configuring from resource: /hibernate.cfg.xml
14:27:35,515 INFO Configuration:1414 - Configuration resource: /hibernate.cfg.xml
14:27:35,593 INFO Configuration:563 - Reading mappings from resource : springapp/domain/Product.hbm.xml
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(6) Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(6) Element type "hibernate-mapping" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(7) Element type "class" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(9) Element type "id" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(10) Element type "generator" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(13) Attribute "column" must be declared for element type "property".
14:27:35,609 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(13) Attribute "type" must be declared for element type "property".
14:27:35,609 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(14) Attribute "column" must be declared for element type "property".
14:27:35,609 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(14) Attribute "type" must be declared for element type "property".
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource springapp/domain/Product.hbm.xml
+-----------------------------------------------------------------------------+
settings:
+-----------------------------------------------------------------------------+
hibernate.cfg.xml:
+-----------------------------------------------------------------------------+
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">1</property>
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<mapping resource="springapp/domain/Product.hbm.xml"/>
</session-factory>
</hibernate-configuration>
+-----------------------------------------------------------------------------+
Product.hbm.xml:
+-----------------------------------------------------------------------------+
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-mapping>
<class name="springapp.domain.Product" table="products">
<id column="id" name="id" type="java.lang.Long">
<generator class="increment"/>
</id>
<property column="description" name="description" type="java.lang.String"/>
<property column="price" name="price" type="java.lang.String"/>
</class>
</hibernate-mapping>
+-----------------------------------------------------------------------------+
Product.java:
+-----------------------------------------------------------------------------+
package springapp.domain;
import java.io.Serializable;
public class Product implements Serializable {
private int id;
private String description;
private Double price;
public void setId(int i) {
id = i;
}
public int getId() {
return id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("Description: " + description + ";");
buffer.append("Price: " + price);
return buffer.toString();
}
}
+-----------------------------------------------------------------------------+
my db schema locate:
http://forum.springframework.org/attachment.php?attachmentid=2003&d=1236777040
my project schema locate:
http://forum.springframework.org/attachment.php?attachmentid=2004&d=1236777046
+-----------------------------------------------------------------------------+
Please help me to solve this problem.
Thanks in advance!