MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
anton1980
Post subject: Scaffolding, one entity, two incoming 'one-to-many' rels  PostPosted: Feb 02, 2011 - 07:11 PM



Joined: Feb 02, 2011
Posts: 2

Hi,

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
 
 View user's profile Send private message  
Reply with quote Back to top
jkennedy
Post subject: RE: Scaffolding, one entity, two incoming  PostPosted: Feb 07, 2011 - 05:21 PM



Joined: Jan 27, 2010
Posts: 245

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,
Jack
 
 View user's profile Send private message  
Reply with quote Back to top
anton1980
Post subject:   PostPosted: Feb 07, 2011 - 11:55 PM



Joined: Feb 02, 2011
Posts: 2

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.

Anton
 
 View user's profile Send private message  
Reply with quote Back to top
luckyhg90
Post subject:   PostPosted: Feb 12, 2011 - 10:13 AM



Joined: Feb 12, 2011
Posts: 1

thanks for sharing

_________________
<a href="http://frontiercheats.com/">frontierville cheats</a><br>
Play frontierville with a good frontierville guide with frontierville cheats.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits