Exposed primary keys. I know them well :-P You can prevent multiple jobs with the same job number with a unique index on the column. If you model an index on that column in entity modeler and make it a 'distinct' index, the migration generator will generate the addUniqueIndex stuff for you.
If you're using postgres, the unique constraint error will include the index name. If you override your ERXSQLHelper's handleDatabaseException method, you can catch it there. You can then figure out what went wrong by inspecting the error and your model's indexes. Then just throw a proper validation exception and let D2W handle the rest. Ramsey On Apr 6, 2012, at 9:43 AM, Theodore Petrosky wrote: > I started typing about the table and I decided to go look and not trust my > memory. I found my error. > > I had created an index on jobNumber. I wanted to make sure that there were no > duplicates. I was hoping that when a user tried to put in a duplicate > jobNumber the error would case an error page to be generated. > > In my haste to create the index, jobNumber was marked to be a primary key. > Removing the primary key in EntityModeler fixed my problem. > > Of course now I have the other problem of what to do when someone uses a > conflicting jobNumber. I didn't get a pretty page saying oops your jobNumber > is already in use. But at least I can now insert 'Briefs'. > > Thanks for making me see the errors of my ways. > > So, is there a d2w way to (or a property) that can check for duplicates in an > attribute? > > Is there an example of validation checking when I press that save button? > > > > ted > > --- On Fri, 4/6/12, David LeBer <[email protected]> wrote: > >> From: David LeBer <[email protected]> >> Subject: Re: D2W creating a new object? >> To: "Theodore Petrosky" <[email protected]> >> Cc: "[email protected] Development" >> <[email protected]> >> Date: Friday, April 6, 2012, 11:58 AM >> Does the DB column type and model >> match? >> >> Is your EO_PK_TABLE up to date (though I think that would >> lead to a more explicit error)? >> >> D >> >> -- >> David LeBer >> Codeferous Software >> >> On 2012-04-06, at 11:34 AM, Theodore Petrosky wrote: >> >>> the primary key is id modeled as an int and it is not >> exposed as a class property. >>> >>> Ted >>> >>> --- On Fri, 4/6/12, Ramsey Gurley <[email protected]> >> wrote: >>> >>>> From: Ramsey Gurley <[email protected]> >>>> Subject: Re: D2W creating a new object? >>>> To: "Theodore Petrosky" <[email protected]> >>>> Cc: "David LeBer" <[email protected]>, >> "[email protected]" >> <[email protected]> >>>> Date: Friday, April 6, 2012, 11:32 AM >>>> >>>> On Apr 6, 2012, at 8:21 AM, Theodore Petrosky >> wrote: >>>> >>>>> I should have also said that I still get the >> error: >>>>> >>>>> >>>> Error: >> java.lang.IllegalStateException: >>>> Adaptor >> com.webobjects.jdbcadaptor.JDBCAdaptor@7f1633fd >>>> failed to provide new primary keys for entity >> 'Brief' >>>> >>>> What is the primary key(s) for brief and how is it >> modeled? >>>> Is it a class property? If the PK is exposed >> as a >>>> class property, you have to set it manually. >>>> >>>> Ramsey >>>> >>>> >> >> > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com > > This email sent to [email protected] _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
