Hello,
I have the following two DB tables:
Code:
CREATE TABLE nat_values(
id Number NOT NULL,
speed Number(3,0),
speed_ff Number(3,0),
CONSTRAINT nat_values_id PRIMARY KEY (id)
)
CREATE TABLE area(
id Number NOT NULL,
id_nat_values Varchar2(15),
area_c Number(4,0),
CONSTRAINT area_id PRIMARY KEY (id)
)
and the correspondent beans:
Code:
public class NatValues extends Entity{
private Integer id;
private Integer speed;
private Integer speed_ff;
private List<Area> areas;
//constructor + get/set
}
public classArea extends Entity {
private Integer id;
private Integer nidC;
//constructor + get/set
}
One object of
nat_values can be related to many objects in
area.
The field
id in both tables is a number, but the field
Area.id_nat_values, which relates an Area to one object of Nat_values is not
nat_values.id, it is a coded string which can be obtained by calling the function
DECODE(Area.id_nat_values).
I use a column transformer to achieve this, which works fine in a many-to-one mapping that I have for some other objects, but it is nt working in this.
This are my mapping files:
Code:
<hibernate-mapping package=".">
<class name="NatValues" table="nat_values" lazy="false">
<id name="id" column="id">
<generator class="assigned"/>
</id>
<property name="speed" column="speed"/>
<property name="speed_ff" column="speed_ff"/>
<bag name="areas" table="AREA" cascade="all" fetch="select" lazy="false">
<key>
<column name="id_nat_values" write="encode_id('AREA', ?)" read="decode_id(id_nat_values)"/>
</key>
<one-to-many class="Area" not-found="exception" />
</bag>
</class>
</hibernate-mapping>
<hibernate-mapping package=".">
<class name="Area" table="area" lazy="false">
<id name="id" column="id">
<generator class="assigned"/>
</id>
<property name="nidC" column="nid_c"/>
</class>
</hibernate-mapping>
When I try to select the elements from nat_values Hibernate doesn't use the column transformers in the select, so it doesn't work and I can not get the list of areas.
any idea why is this happening?