idescola e idaluno
<label for="idescola">Escola</label>
<div class="div_texbox">
<select name="escola">
<c:forEach var="escola" items="${escolas}">
<option value="${escola.idescola}" ${escola.idescola eq aluno.escola.idescola ? "SELECTED" : ""}>${escola.idescola}</option>
</c:forEach>
</select>
</div>
CREATE TABLE IF NOT EXISTS `aluno_escola` (
`idaluno` int(10) unsigned NOT NULL,
`idescola` int(10) unsigned NOT NULL,
PRIMARY KEY (`idaluno`,`idescola`),
KEY `fk_aluno_has_escola_escola1` (`idescola`),
KEY `fk_aluno_has_escola_aluno1` (`idaluno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`aluno_escola`
`fk_aluno_has_escola_aluno1` FOREIGN KEY (`idaluno`) REFERENCES `aluno` (`idaluno`) ON DELETE NO ACTION ON UPDATE NO ACTION,
fk_aluno_has_escola_escola1` FOREIGN KEY (`idescola`) REFERENCES `escola` (`idescola`) ON DELETE NO ACTION ON UPDATE NO ACTION;
arquivos xml do aluno
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 05/10/2011 15:06:12 by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="Bean.Aluno" table="aluno" catalog="sge">
<id name="idaluno" type="java.lang.Integer">
<column name="idaluno" />
<generator class="identity" />
</id>
<property name="nome" type="string">
<column name="nome" length="45" />
</property>
<property name="endereco" type="string">
<column name="endereco" length="45" />
</property>
<property name="sexo" type="string">
<column name="sexo" length="1" />
</property>
<property name="nomepai" type="string">
<column name="nomepai" length="45" />
</property>
<property name="nomemae" type="string">
<column name="nomemae" length="45" />
</property>
<property name="resposavel" type="string">
<column name="resposavel" length="45" />
</property>
<property name="nacionalidade" type="string">
<column name="nacionalidade" length="45" />
</property>
<property name="naturalidade" type="string">
<column name="naturalidade" length="45" />
</property>
<property name="uf" type="string">
<column name="uf" length="2" />
</property>
<property name="municipio" type="string">
<column name="municipio" length="45" />
</property>
<property name="escola" type="string">
<column name="escola" length="45" />
</property>
<property name="datanascimento" type="timestamp">
<column name="datanascimento" length="0" />
</property>
<property name="telefone" type="string">
<column name="telefone" length="15" />
</property>
<property name="resistro" type="string">
<column name="resistro" length="20" />
</property>
<set name="escolas" inverse="false" table="aluno_escola">
<key>
<column name="idaluno" not-null="true" />
</key>
<many-to-many entity-name="Bean.Escola">
<column name="idescola" not-null="true" />
</many-to-many>
</set>
</class>
</hibernate-mapping>
escola
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 05/10/2011 15:06:12 by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="Bean.Escola" table="escola" catalog="sge">
<id name="idescola" type="java.lang.Integer">
<column name="idescola" />
<generator class="identity" />
</id>
<property name="nome" type="string">
<column name="nome" length="45" />
</property>
<property name="endereco" type="string">
<column name="endereco" length="45" />
</property>
<property name="bairro" type="string">
<column name="bairro" length="45" />
</property>
<property name="telefone" type="string">
<column name="telefone" length="45" />
</property>
<property name="email" type="string">
<column name="email" length="45" />
</property>
<property name="cidade" type="string">
<column name="cidade" length="45" />
</property>
<property name="uf" type="string">
<column name="uf" length="2" />
</property>
<property name="inep" type="string">
<column name="inep" length="45" />
</property>
<property name="leiatorizacao" type="string">
<column name="leiatorizacao" />
</property>
<property name="dependencia" type="string">
<column name="dependencia" length="45" />
</property>
<property name="cnpj" type="string">
<column name="cnpj" length="45" />
</property>
<set name="alunos" inverse="true" table="aluno_escola">
<key>
<column name="idescola" not-null="true" />
</key>
<many-to-many entity-name="Bean.Aluno">
<column name="idaluno" not-null="true" />
</many-to-many>
</set>
</class>
</hibernate-mapping>