Ola pessoal,
Estou com dificuldade em rodar uma pequena aplicação de duas tabelas.
1 Municipio para N Praia
hibernate.cfg.xml<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="org/hibernate/SessionFactory">
<!-- properties -->
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/sin
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="show_sql">true</property>
<property name="connection.username">root</property>
<property name="connection.password">123</property>
<!-- mapping files -->
<mapping resource="map/Municipio.hbm.xml" />
<mapping resource="map/Praia.hbm.xml" />
</session-factory>
</hibernate-configuration>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="bean.Municipio" table="municipio">
<id name="codMunicipio" column="codMunicipio" type="int">
<generator class="native">
</generator>
</id>
<property name="descMunicipio" type="java.lang.String" column="descMunicipio"/>
<one-to-many name="praia" class="Praia"column="codPraia" />
</class>
</hibernate-mapping>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="bean.Praia" table="praia">
<id name="codPraia" column="codPraia" type="int">
<generator class="native">
</generator>
</id>
<property name="descPraia" type="java.lang.String" column="descPraia"/>
<many-to-one name="municipio"class="Municipio"column="codMunicipio" />
</set>
</class>
</hibernate-mapping>
package testes;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import bean.Municipio;
public class AddMunicipio {
public static void main(String[] args) {
SessionFactory sf = new Configuration().configure("/conf/hibernate.cfg.xml").buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
Municipio municipio = new Municipio();
municipio.setDescMunicipio("palhoça");
session.save(municipio);
tx.commit();
session.close();
}
}
Aparece o seguinte erro:
Error on line 12 of document : Element type "one-to-many" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "one-to-many" must be followed by either attribute specifications, ">" or "/>"
Alguem poderia me dar um help?
Obrigado
