MyEclipse: Scaffolding, one entity, two incoming 'one-to-many' rels anton1980 - Feb 02, 2011 - 07:11 PM Post subject: Scaffolding, one entity, two incoming 'one-to-many' rels
Hi,
As you can guess, Vendor and Invoice are one-to-many and Status and Invoice are one-to-many.
When I generate the code with Scaffolding, everything seems to go fine, there are no errors or anything. The application starts up fine too. However, if I want to add an Invoice I can either do that through a Vendor or a Status, but that does not work. There are constraints on the database, which require that both vendor and status were defined for an Invoice. So, if I add an Invoice through Vendor then Status is null and the database produces an error.
Can this type of setup be maintained in Spring DSL or I will need to get it to work manually? Please give me some pointers on how to proceed... Thanks!
Antonjkennedy - Feb 07, 2011 - 05:21 PM Post subject: RE: Scaffolding, one entity, two incoming
Anton,
Which UI technology are you using? The reason I ask is because they each have slight differences.
In general, if your rdbms has foreign key constraints against two relationships, then you would need to setup both relationships prior to persisting as you have stated.
I think your best bet would be to add to or extend the generated code to create a composition of generated "pieces" that allow your users to define all of the required data at one time, either in one webflow, or in one jsp form, or one GWT UI, etc, depending on the front end option you are using.
Let me know if you don't see a clear path to achieve that goal.
Thanks,
Jackanton1980 - Feb 07, 2011 - 11:55 PM Post subject:
Hi Jack,
Thank you for your response.
We are using web flow.
I did exactly what you are suggesting. I added a method to the service which allows the user to set two entities simultaneously. I guess thought I was missing something and there was another way of doing it, but this works just fine.
Antonluckyhg90 - Feb 12, 2011 - 10:13 AM Post subject:
thanks for sharing