Hello,
I've a problem and perhaps someone can help me.
I have two tables "Item" and "Molecule". There is a one-to-one relationship between them, but I get a many-to-one relationship created in the mapping file. Why?
(I designed the database schema with dbdesigner 4.)
So, if someone can help me that would be great.
Greetz Carina
Hibernate version: 3.2 beta 8
Name and version of the database you are using: Oracle 10g
Create Statement of the tables:
Code:
CREATE TABLE item (
id INTEGER NOT NULL ,
type VARCHAR(45) NULL,
PRIMARY KEY(id)
);
CREATE TABLE molecules (
item_id INTEGER NOT NULL,
name VARCHAR(100) NULL,
smiles VARCHAR(100) NULL,
iupac VARCHAR(100) NULL,
inchi VARCHAR(100) NULL,
formula VARCHAR(100) NULL,
createBy VARCHAR(100) NULL,
nofAtoms INT NULL,
nofBonds INT NULL,
nofHeavyAtoms INT NULL,
nofHeavyBonds INT NULL,
nofFragments INT NULL,
nofSuperAtoms INT NULL,
nofRings INT NULL,
nofRGroups INT NULL,
medianBondLength DOUBLE PRECISION NULL,
mass DOUBLE PRECISION NULL,
directory VARCHAR(100) NULL,
workflowID INTEGER NULL,
PRIMARY KEY(item_id),
FOREIGN KEY(item_id)
REFERENCES item(id)
);
CREATE SEQUENCE item_seq
start with 1
increment by 1
nomaxvalue;
CREATE TRIGGER item_trigger
before insert on item
for each row
begin
SELECT item_seq.nextval into :new.id from dual;
end;
/
Mapping file:Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 23, 2007 4:53:05 PM by Hibernate Tools 3.2.0.beta8 -->
<hibernate-mapping>
<class name="de.fhg.scai.bio.csr.io.database.hibernate.Item" table="ITEM">
<id name="id" type="int">
<column name="ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="type" type="string">
<column name="TYPE" length="45" />
</property>
<set name="moleculeses" inverse="true">
<key>
<column name="ITEM_ID" precision="22" scale="0" not-null="true" unique="true" />
</key>
<one-to-many class="de.fhg.scai.bio.csr.io.database.hibernate.Molecules" />
</set>
</class>
</hibernate-mapping>