Beginner |
|
Joined: Sat Oct 18, 2003 8:00 pm Posts: 22
|
Hi
I'm trying to map an NxM relation between two entities. It's a database with systems (sistema) and users (usuarios) of this systems.
"Caused by: net.sf.hibernate.MappingException: duplicate import: Usuario"
I don't reference any map file at the code, just use the "Configuration().configure().buildSessionFactory();" command.
I have the following configuration:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@host:1521:db</property>
<property name="hibernate.connection.username">admsist</property>
<property name="hibernate.connection.password">password</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
net.sf.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="gov/tresc/admsist/model/Usuario.hbm.xml"/>
<mapping resource="gov/tresc/admsist/model/Sistema.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Usuario.hbm.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="gov.tresc.admsist.model.Usuario" table="USUARIO"
schema="ADMSIST">
<id name="id" column="IDO_USUARIO" type="long">
<generator class="increment"/>
</id>
<property name="nome" column="NOME_USUARIO" type="string"
length="70" not-null="true"/>
<property name="nome" column="NOME_USUARIO" type="string" length="70"
not-null="true"/>
<property name="login" column="LOGIN" type="string" length="70"
not-null="true"/>
<property name="eMail" column="E_MAIL" type="string" length="70"
not-null="true"/>
</class>
</hibernate-mapping>
Sistema.hbm.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="gov.tresc.admsist.model.Sistema" table="SISTEMA"
schema="ADMSIST">
<id name="id" column="IDO_SISTEMA" type="long">
<generator class="increment"/>
</id>
<property name="nomeSistema" column="NOME_SISTEMA" type="string"
length="40" not-null="true"/>
<property name="estacoesAcesso" column="ESTACOES_ACESSO" type="string"
length="80"/>
<set name="usuarios" inverse="true" table="USUARIO_SISTEMA">
<key column="IDO_SISTEMA"/>
<many-to-many column="IDO_USUARIO" class="gov.tresc.admsist.model.Usuario"/>
</set>
</class>
</hibernate-mapping>
|
|