- This topic has 3 replies, 3 voices, and was last updated 14 years ago by
luckyhg90.
-
AuthorPosts
-
anton1980MemberHi,
These are my entities:
Vendor (id, name)
Status (id, name)
Invoice (id, amount, vendor_id, status_id)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!
Anton
jkennedyMemberAnton,
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,
Jack
anton1980MemberHi 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.
Anton
luckyhg90Memberthanks for sharing
-
AuthorPosts