I'm still having a problem mapping my classes. Something weird is happening and don't know why!!
The problem is:
When i call
session.save(aumento); Hibernate would insert
aumento and then insert each
detalle and finally each valor
corresponding to the
detalle mentioned. After inserting the records, Hibernate performs un
update for each
valor, that's one of the weird things that happens. The other issue happens randomly, an exception is thrown:
org.hibernate.PropertyAccessException
:exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of ar.com.osde.sigma.model.consumo.aumento.AumentoDetalle.?
I did changed "hibernate.cglib.use_reflection_optimizer" property to false and nothing happens. It may be a common message
for this kind of exception...
If you pay attention carefully to the message of the exception you would see that the property refered that belongs to AumentoDetalle
is a question mark!!! (
?). Can anyone tell me what does it mean? I debugged Hibernate sources but can't find the problem
or how to solve it if a problems exists....
In the lines below, i'm showing the class structure and mapping files...
I have three tables:
Code:
create table Aumentos ( aumentos_id int not null primary key, ....... )
create table Aumentos_Detalle ( aumentos_id int not null, mod_sec_cc_id int not null, mod_sec_especialidad_id int not null, primary key (aumentos_id, mod_sec_cc_id, mod_sec_especialidad_id) )
create table Aumentos_Valor ( aumentos_id int not null, mod_sec_cc_id int not null, mod_sec_especialidad_id int not null, mod_sec_plan_id int not null, primary key (aumentos_id, mod_sec_cc_id, mod_sec_especialidad_id, mod_sec_plan_id) , .... )
The classes:
Code:
public class Aumento extends ... implements ... {
....
/** <AumentoDetalle> */
private Set detalles = new HashSet();
....
}
Code:
public class AumentoDetalle extends ... implements ... {
....
private SecundariaModalidad modalidadCentroCosto = null;
private SecundariaModalidad modalidadEspecialidad = null;
/** Bidirectional association */
private Aumento aumento;
/** <AumentoValor> */
private Set valores = new HashSet();
....
}
Code:
public class AumentoValor extends ... implements ... {
....
private SecundariaModalidad modalidadCentroCosto = null;
private SecundariaModalidad modalidadEspecialidad = null;
private SecundariaModalidad modalidadPlan = null;
}
And, finally the mapping files:
Aumento.hbm.xml
Code:
....
<set cascade="all,delete-orphan" name="detalles" lazy="true" inverse="true" >
<key column="id_aumentos" foreign-key="true" not-null="true" update="false" />
<one-to-many class="ar.com.osde.sigma.model.consumo.aumento.AumentoDetalle" />
</set>
....
AumentoDetalle.hbm.xml
Code:
....
<composite-id>
<key-many-to-one name="aumento" column="id_aumentos" />
<key-many-to-one name="modalidadCentroCosto" column="id_mod_sec_cc" />
<key-many-to-one name="modalidadEspecialidad" column="id_mod_sec_especialidad" />
</composite-id>
...
<set cascade="all" name="valores" lazy="true" >
<key foreign-key="true" not-null="true">
<column name="id_aumentos" />
<column name="id_mod_sec_cc" />
<column name="id_mod_sec_especialidad" />
</key>
<one-to-many class="ar.com.osde.sigma.model.consumo.aumento.AumentoValor" />
</set>
....
AumentoValor.hbm.xml
Code:
....
<composite-id>
<key-many-to-one name="modalidadPlan" column="id_mod_sec_plan" />
<key-many-to-one name="modalidadFilial" column="id_mod_sec_filial" />
</composite-id>
...
Any ideas?
Thanks in advance,
Nicolas Gonzalez
Buenos Aires - Argentina
P.S.: Sorry for my english!!