Dear members,
I have a relation like this:
Code:
Shareholder ShareholderType
type --> shareholder_type_id
so type is a foreign key of shareholder_type_id.
I would like to get on the generated class the attribute name of type to be mapped into type instead of default generation setting which is: shareholderType.on the Shareholder.hbm.xml file I get (using hbm2hbmxml)
Code:
<many-to-one name="shareholderType" class="com.schinvest.lra.domain.ShareholderType" fetch="select">
<column name="type" not-null="true" />
</many-to-one>
but I would like to get instead shareholderType name the simple name type.
Looking into the Hibernate Tool documentation, you can redefine some properties on the reverse enginerring process, but for me it is confuse, because there is information about the foreign key setting on multiple places, for example, on column node:
Code:
<column
name="column_name"
jdbc-type="java.sql.Types type"
type="hibernate_type"
property="propertyName"
exclude="true|false"
foreign-catalog="catalogName"
foreign-schema="schemaName"
foreign-table="tableName"
foreign-column="columnName"
/>
and also there is a node <foreign-key> inside the node table with the following information:
Code:
<foreign-key
name="foreignKeyName"
foreign-catalog="catalogName"
foreign-schema="schemaName"
foreign-table="tableName"
>
<column-ref local-column="columnName" foreign-column="foreignColumnName"/>
</foreign-key>
where do I have to change the information in order to really get type on the Shareholder class?
(Note: The root table definition should be something like this:
Code:
<table
catalog="catalog_name"
schema="schema_name"
name="table_name"
class="ClassName"
>
<primary-key...>
<column...>
<foreign-key...>
</table>
)
The table definition is:
Quote:
CREATE TABLE shareholder_type (
shareholder_type_id INT(2) UNSIGNED NOT NULL AUTO_INCREMENT
, name VARCHAR(10) NOT NULL
, PRIMARY KEY (shareholder_type_id)
)TYPE=InnoDB;
CREATE TABLE shareholder (
shareholder_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT
, type INT(2) UNSIGNED NOT NULL
, CONSTRAINT fk_shareholder_2 FOREIGN KEY (type)
REFERENCES shareholder_type (shareholder_type_id)
)TYPE=InnoDB;
ALTER TABLE shareholder COMMENT='Share holders information'
I have tried with some change combinations but I didn't get the expected result.
Thanks in advance,
David Leal