I have table which does not have a primary key however it has column which is unique. my question is how do i write the mapping document for this type of sort of tables? any how here is my sql statement for the table:
Code:
create table test(
test_id varchar(210),
message varchar(210)
);
insert into test(test_id, message)values(1, 'aertaer');
insert into test(test_id, message)values(2, 'traraer');
Please note 'test_id' is unique.
Many thanks
Hibernate version:3
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="testhibernate.Test" table="Test">
<property name="TestId" column="test_id" type="java.lang.String" unique="true"/>
<property name="Message" column="message" type="java.lang.String" />
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
SEVERE: Error parsing XML: XML InputStream(8) 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)*)".
Exception in thread "main" java.lang.ExceptionInInitializerError
at testhibernate.Main.main(Main.java:27)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource testhibernate/test.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at testhibernate.DAO.<clinit>(DAO.java:22)
... 1 more
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:502)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 8 more
Name and version of the database you are using:
MySQL4