Pete Pron [
http://community.jboss.org/people/pete2k] created the discussion
"cant get one-to-one reverse engineering to work for me"
To view the discussion, visit:
http://community.jboss.org/message/559680#559680
--------------------------------------------------------------
Hi everyone,
I'm using the Jboss hibernate tools to reverse engineer an existing database and
generating java + hbm.
Currently I'm becoming desperate by trying to resolv an one-to-one mapping. There is
always a one-to-many & many-to-one
generated and I don't know what to do.
Its fine for me that the tools are trying to create a one-to-many (it could be) but
I'm searching for a way to define this relationship as one-to-one.
First of all:
Its an Oracle 10 Database and Hibernatetools Version: 3.3.0.v20100720-0040-H162-M1
Detect one-to-one associations is turned on.
Here is the relevant SQL:
-----------------------------------------------------------------------------------------
CREATE TABLE EXT_ADDRESS (
ID NUMBER(22 , 0) NOT NULL,
...
<many attributes>
..
ADDRESS_ID NUMBER(22 , 0) NOT NULL
);
CREATE TABLE ADDRESS (
ID NUMBER(22 , 0) NOT NULL,
...
<many attributes>
);
ALTER TABLE EXT_ADDRESS ADD CONSTRAINT EXT_ADR_PK PRIMARY KEY (ID);
ALTER TABLE ADDRESS ADD CONSTRAINT ADR_PK PRIMARY KEY (ID);
ALTER TABLE EXT_ADDRESS ADD CONSTRAINT EXT_ADR_FK FOREIGN KEY (ADDRESS_ID)
REFERENCES ADDRESS (ID)
ON DELETE RESTRICT
ON UPDATE CASCADE;
-----------------------------------------------------------------------------------------
Here what I already tried to do in my hibernate.reveng.xml:
-----------------------------------------------------------------------------------------
<table name="EXT_ADDRESS" >
<column name="ID" type="long"></column>
<foreign-key constraint-name="EXT_ADR_FK">
<!-- <many-to-one exclude="true"/>
<set exclude="true" /> -->
<one-to-one exclude="false"/>
<inverse-one-to-one exclude="false"/>
</foreign-key>
</table>
-----------------------------------------------------------------------------------------
This doesn't work and there is always a Set of ExtAddress defined in Address. The
table definition and the foreign
key should be correct. If i uncomment the many-to-one and set with exclude true the set is
removed.
Any help is highly appreciated. Thanks
Pete
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/559680#559680]
Start a new discussion in JBoss Tools at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]