On 2012-08-04, at 12:46 PM, "Sr. Ângelo Andrade Cirino" <[email protected]> wrote:
> Hi David, > > Thank you for your help. I managed to find the problem. Due to the mess with > the migrations and then deleting and rebuilding the tables, I noticed that > the inherited relationships in ERDatabaseAttachment, ERFileAttachment and > ERS3Attachment weren't deleted, so after deleting them and creating just one > entity for an attachment, I was able to solve that problem. > > I simplified the model to use just one image and the ERMD2WEditAttachment > component worked properly. But then another problem arose. Maybe it is due to > the relationship I set up in EOModeler. Unfortunately the screen capture of > your example arrived unreadable (half of the image in black) and I couldn't > use it as a model for my own relationship. This is the screen capture of the > relationship I created: > > <Captura de Tela 2012-08-04 às 16.42.36.png> You can't create a foreign key in the ERAttachment tables. It just creates problems. David > > The error I am getting now is this: > > EOGeneralAdaptorException: EvaluateExpression failed: > <com.webobjects.jdbcadaptor._MySQLPlugIn$MySQLExpression: "INSERT INTO > ERAttachment(size, width, height, attachmentDataID, available, thumbnail, > creationDate, ownerID, configurationName, smallData, mimeType, > originalFileName, webPath, id, proxied, storageType) VALUES (?, NULL, NULL, > ?, ?, NULL, ?, NULL, NULL, NULL, ?, ?, ?, ?, ?, ?)" withBindings: > 1:18160(size), 2:3(attachmentDataID), 3:true(available), 4:2012-08-04 > 16:13:54(creationDate), 5:"image/jpeg"(mimeType), > 6:"miniatura.jpg"(originalFileName), 7:"/8.jpg"(webPath), 8:8(id), > 9:true(proxied), 10:"db"(storageType)>: > Next exception:SQL State:23000 -- error code: 1452 -- msg: Cannot add or > update a child row: a foreign key constraint fails > (`visiontur`.`erattachment`, CONSTRAINT `ERAttachment_attachmentDataID_id_FK` > FOREIGN KEY (`attachmentDataID`) REFERENCES `ERAttachmentData` (`id`)) > at > com.webobjects.eoaccess.EODatabaseContext._exceptionWithDatabaseContextInformationAdded(EODatabaseContext.java:4504) > > It seems to be a problem with the ERAttachment_attachmentDataID_id_FK foreign > key in ERAttachmentData. I guess that after solving this issue I will be able > to use the ERAttachment. > > I indeed considered using one single image with the remaining two being > created on the fly with ImageMagik, but since the three images not only have > three different dimensions, but also three different aspect ratios that > demand user intervention, I decided to leave the creation of the three images > to the user. Otherwise I will have to use a JavaScript interface to determine > the sizes and a custom component. This JavaScript option with a custom > component is the best and most elegant solution, but I am in a hurry and > decided to leave it as a delayed requirement. > > Best regards, > > Angelo > > Em 04/08/2012, às 00:31, David Holt escreveu: > >> >> On 2012-08-03, at 8:12 AM, Sr. Ângelo Andrade Cirino <[email protected]> >> wrote: >> >>> Hi David, >>> >>> At first sight the relationships look correct. I have an entity that can >>> hold three different pictures, so I decided to use three attributes, one >>> for each picture. >> >>> The pictures are optional. >> >> Double check that is correct in your model. >> >>> The database is being updated to a certain level, since I can see that the >>> private keys are being automatically incremented. As can be seen in the >>> picture, there are three images and the component will complain that one of >>> two is missing, either "Small Picture" or "Big Picture". It doesn't matter >>> if I try to insert just the thumbnail, leaving the other two attachments >>> empty, the component will always complain that ERDatabaseAttachment >> >> You could try putting the Attachment component on separate tabs. Check if >> there is a problem with three of them in the same page. I've only ever used >> one. Have you considered processing the images on the fly with something >> like ImageMagik so that you upload once and then the other sizes are created >> for you on the fly and added to the attachments? >> >> Did you turn off creating the key in the ERAttachment side of your >> relationships when you created them? >> >> <Screen Shot 2012-08-03 at 8.24.44 PM.png> >> >>> must have one image, either one of the two mentioned. >>> >>> I used EOModeler to create the relationships, in my database table I just >>> provided the columns to store the private keys for the images in >>> ERAttachment. >> >> The code below looks perfect. >> >>> The relationship is modeled as optional one-to-one, for instance >>> Pacote.imagemGrandeID => ERAttachment.id. This is the code generated by >>> EOGenerate: >>> >>> public er.attachment.model.ERAttachment imagemGrande() { >>> return >>> (er.attachment.model.ERAttachment)storedValueForKey(_Pacote.IMAGEM_GRANDE_KEY); >>> } >>> >>> public void setImagemGrande(er.attachment.model.ERAttachment value) { >>> takeStoredValueForKey(value, _Pacote.IMAGEM_GRANDE_KEY); >>> } >>> >>> public void setImagemGrandeRelationship(er.attachment.model.ERAttachment >>> value) { >>> if (_Pacote.LOG.isDebugEnabled()) { >>> _Pacote.LOG.debug("updating imagemGrande from " + imagemGrande() + " >>> to " + value); >>> } >>> if >>> (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) >>> { >>> setImagemGrande(value); >>> } >>> else if (value == null) { >>> er.attachment.model.ERAttachment oldValue = imagemGrande(); >>> if (oldValue != null) { >>> >>> removeObjectFromBothSidesOfRelationshipWithKey(oldValue, >>> _Pacote.IMAGEM_GRANDE_KEY); >>> } >>> } else { >>> addObjectToBothSidesOfRelationshipWithKey(value, >>> _Pacote.IMAGEM_GRANDE_KEY); >>> } >>> } >>> >>> Thanks for the help, >>> >>> Angelo >>> >>> Em 03/08/2012, às 11:06, David Holt escreveu: >>> >>>> What does your model for ERAttachment to your entity look like? >>>> >>>> What have you created the relationship(s) on? >>>> >>>> d >>>> >>>> On 2012-08-03, at 4:52 AM, Sr. Ângelo Andrade Cirino <[email protected]> >>>> wrote: >>>> >>>>> Hi, >>>>> >>>>> By disabling the properties for migrations in my application's properties >>>>> file I was able to launch the app, but I am getting an error trying to >>>>> use ERAttachment with D2W and three properties bound to >>>>> ERD2WDisplayAttachment for editing. The D2W interface presents the error >>>>> shown in the following screen capture: >>>>> >>>>> <Captura de Tela 2012-08-02 às 22.12.48.png> >>>>> >>>>> and the console reports this (among similar messages): >>>>> >>>>> Ago 02 22:03:20 Visiontur[60741] DEBUG NSLog Page: >>>>> er.modern.look.pages.ERMODTabInspectPage - Configuration: EditPacote - >>>>> Updating primary key value for ERAttachment in PK table named: >>>>> EO_PK_TABLE to seed value: 21 >>>>> Ago 02 22:03:20 Visiontur[60741] DEBUG NSLog Page: >>>>> er.modern.look.pages.ERMODTabInspectPage - Configuration: EditPacote - >>>>> evaluateExpression: >>>>> <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "UPDATE >>>>> EO_PK_TABLE SET PK = 21 WHERE NAME = 'ERAttachment' AND PK = 20" >>>>> withBindings: > >>>>> Ago 02 22:03:20 Visiontur[60741] DEBUG NSLog Page: >>>>> er.modern.look.pages.ERMODTabInspectPage - Configuration: EditPacote - >>>>> === Commit Internal Transaction >>>>> >>>>> Strangely, the bindings are missing. I am not sure what this means, but >>>>> maybe the ERD2WDisplayAttachment component needs some tweaking through >>>>> rules that I am missing. The specific rule I am using is this: >>>>> >>>>> 100 : ((task = 'edit' or task = 'create') and (propertyKey = 'miniatura' >>>>> or propertyKey = 'imagemPequena' or propertyKey = 'imagemGrande')) => >>>>> componentName = "ERMD2WEditAttachment" >>>>> [com.webobjects.directtoweb.Assignment] >>>>> >>>>> Thanks, >>>>> >>>>> Angelo >>>>> _______________________________________________ >>>>> 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/programmingosx%40mac.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]
