Hibernate version:2.1.4
I'have a BeanCittadino therefore:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- it.publisys.anagrafe.condivisi.BeanPersona root -->
<class name="it.publisys.anagrafe.condivisi.BeanPersona" table="Persona" discriminator-value="P">
<id name="id" type="java.lang.Integer" column="ID">
<generator class="native"/>
</id>
<discriminator column="tipo" type="java.lang.String" length="1"/>
<!-- it.publisys.anagrafe.condivisi.BeanCittadino -->
<property name="nome" column="nome" type="java.lang.String" length="80" find="true" displayLabel = "Nome"/>
<property name="cognome" column="cognome" type="java.lang.String"/>
<property name="sesso" column="sesso" type="java.lang.String"/>
<subclass name="it.publisys.anagrafe.condivisi.BeanCittadino" discriminator-value="C">
<property name="dataNascita" column="dataNascita" type="java.sql.Date"/>
<many-to-one
name="attoNascitaTrascritto"
class="it.publisys.anagrafe.condivisi.BeanAtto" cascade="none" outer-join="true">
<column name="ATTONASCITATRASCRITTO" />
</many-to-one>
<many-to-one
name="attoNascitaOriginale"
class="it.publisys.anagrafe.condivisi.BeanAtto" cascade="none" outer-join="true">
<column name="ATTONASCITAORIGINALE" />
</many-to-one>
<many-to-one name="padre" class="it.publisys.anagrafe.condivisi.BeanPersona" cascade="none" outer-join="true">
<column name="PADRE"/>
</many-to-one>
<many-to-one name="madre" class="it.publisys.anagrafe.condivisi.BeanPersona" cascade="none" outer-join="true">
<column name="MADRE"/>
</many-to-one>
<property name="codiceFiscale" column="codiceFiscale" type="java.lang.String"/>
<property name="dataMorte" column="dataMorte" type="java.sql.Date"/>
<property name="annoNascita" column="annoNascita" type="java.lang.Integer"/>
<property name="codiceCittadino" column="codicecittadino" type="java.lang.Integer"/>
<many-to-one name="comuneNascita" class="it.publisys.anagrafe.condivisi.BeanComuni"
cascade="none" outer-join="true">
<column name="COMUNENASCITA"/>
</many-to-one>
<many-to-one name="comuneMorte" class="it.publisys.anagrafe.condivisi.BeanComuni" cascade="none" outer-join="true">
<column name="COMUNEMORTE"/>
</many-to-one>
<many-to-one
name="attoMorteOriginale"
class="it.publisys.anagrafe.condivisi.BeanAtto" cascade="none" outer-join="true">
<column name="ATTOMORTEORIGINALE" />
</many-to-one>
<many-to-one
name="attoMorteTrascritto"
class="it.publisys.anagrafe.condivisi.BeanAtto" cascade="none" outer-join="true">
<column name="ATTOMORTETRASCRITTO" />
</many-to-one>
<set name="storicoCittadinanza" inverse="true" lazy="true" >
<key column="cittadino"/>
<one-to-many class="it.publisys.anagrafe.condivisi.BeanStoricoCittadinanza"/>
</set>
</subclass>
</class>
</hibernate-mapping>
Where storicoCittadinanza is an HashSet that contains an array of BeanStoricoCittadinanza.
BeanStoricoCittadinanza is:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- it.publisys.anagrafe.condivisi.BeanStoricoCittadinanza root -->
<class name="it.publisys.anagrafe.condivisi.BeanStoricoCittadinanza" table="StoricoCittadinanza">
<id name="ID" type="integer" column="ID" >
<generator class="native" />
</id>
<property name="dataEvento" column="DATAEVENTO" type="java.sql.Date" find="true" displayLabel = "dataEvento"/>
<property name="dataFine" column="DATAFINE" type="java.sql.Date"/>
<property name="dataFineRegistrazione" column="DATAFINEREGISTRAZIONE" type="java.sql.Date"/>
<property name="dataRegistrazione" column="DATAREGISTRAZIONE" type="java.sql.Date"/>
<many-to-one name="cittadinanza" class="it.publisys.anagrafe.condivisi.BeanStati">
<column name="CITTADINANZA" />
</many-to-one>
<!--
<many-to-one name="cittadino" class="it.publisys.anagrafe.condivisi.BeanCittadino">
<column name="CITTADINO" />
</many-to-one>
-->
</class>
</hibernate-mapping>
The problem is when Hibernate initialize the files hbm and tries to mapping the one to many association. It comes raised an exception in the Servlet's init() method. This is the exception:
11:39:49,562 INFO Binder:229 - Mapping class: it.publisys.anagrafe.condivisi.BeanPersona -> Persona
11:39:49,562 DEBUG Binder:462 - Mapped property: id -> ID, type: integer
11:39:49,562 DEBUG Binder:462 - Mapped property: nome -> nome, type: string
11:39:49,562 DEBUG Binder:462 - Mapped property: cognome -> cognome, type: string
11:39:49,562 DEBUG Binder:462 - Mapped property: sesso -> sesso, type: string
11:39:49,562 INFO Binder:169 - Mapping subclass: it.publisys.anagrafe.condivisi.BeanCittadino -> Persona
11:39:49,562 DEBUG Binder:462 - Mapped property: dataNascita -> dataNascita, type: date
StandardContext[/Anagrafe]: Servlet /Anagrafe threw load() exception: javax.servlet.ServletException: Servlet.init() for servlet Inizializza threw exception
javax.servlet.ServletException: Servlet.init() for servlet Inizializza threw exception
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:946)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:810)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3279)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3421)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:638)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
at org.apache.catalina.core.StandardService.start(StandardService.java:388)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:506)
at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
[/b]
|