I mean "Has anyone implemented 1 to n relationships using sql2java?" Example: a Person has multiple addresses(Home, Work, ...) and telephones (Home, Work, Cell, Beep, Fax, ...) giving two 1-n relationships.
Rather than stumbling over various painful objects I'd like to take advantage of other's past pain ;-)
Les
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you have 3 tables, Person, Address, Telephone and some foreign keys defined, sql2java will generate some nice code for you so you can call for example:
I was hoping that someone had actually done such - because AddressManager.getInstance().loadByPersonid(person.getPersonid()) in the 1-n case will return some number of Address objects. The question is how are they returned, how does one iterate them, ...
AND, going the other way how does one stuff them into the DB to start with and later (updates).
Am I right to guess that no one has done more than 1-1 relationships?
Les
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Has anyone done this?
If so, will you share your approach?
Les
Hi there,
what do you mean exactly?...
I mean "Has anyone implemented 1 to n relationships using sql2java?" Example: a Person has multiple addresses(Home, Work, ...) and telephones (Home, Work, Cell, Beep, Fax, ...) giving two 1-n relationships.
Rather than stumbling over various painful objects I'd like to take advantage of other's past pain ;-)
Les
If you have 3 tables, Person, Address, Telephone and some foreign keys defined, sql2java will generate some nice code for you so you can call for example:
(I am just guessing your column names):
AddressManager.getInstance().loadByPersonid(person.getPersonid())
TelephoneManager.getInstance().loadByPersonid(person.getPersonid())
RIGHT! That's the sort of thing I expected.
I was hoping that someone had actually done such - because AddressManager.getInstance().loadByPersonid(person.getPersonid()) in the 1-n case will return some number of Address objects. The question is how are they returned, how does one iterate them, ...
AND, going the other way how does one stuff them into the DB to start with and later (updates).
Am I right to guess that no one has done more than 1-1 relationships?
Les
> how are they returned
An array of AddressBean objects
> how does one iterate them,
We return them all in the array,.
We will soon provide iteration feature using 'generics' and rowset
> how does one stuff them into
> the DB to start with and later (updates).
In each manager we generate a save() method... take a look at it, it handles insert and update operation.
> no one has done more than 1-1 relationships?
Not sure I understand your concern,
I personnaly use 1-n relationship and sql2java