Hi,
i'm creating my db model using hibernate tools in eclipse. My database has two table, without foreign key:
Customer
-name (key)
-age
-state
Sales
-year
-customer
-value
I import my db in eclipse using the hibernate configuration file, and i obtain three java objects:
CustomerId
Customer
Sales
I have to define a relationship between these two objects, in order to use then in the model: Customer 1-n Sales.
How i have to create this relation?
I tried to use this structure, but it doesnt work, mybe because i don't have a foreign key on the db:
Code:
<class name="Sales">
....
<many-to-one name="salescustomer"
column="customer"
not-null="true"/>
</class>
<class name="Customer">
....
<set name="customersales" inverse="true">
<key column="name"/>
<one-to-many class="it.pack.Sales"/>
</set>
</class>
Thanks
Alessandro