Hello everyone.
I am trying to figure out for some hours why I get this
exception without any luck.
I have an Domain/Persist class with all the setters and
getters, also in setters the
this.markModifiedPersistenceState() method called (I
think this is correct)...
What I do is that from one servlet I insert data within
database, here is the code:
=======================
// Now if the file save was OK on the server we
save the information within database also.
Chm62edtNatureObjectPicturePersist
pictureObject = new Chm62edtNatureObjectPicturePersist
();
pictureObject.setDescription(description);
pictureObject.setFileName(filename);
pictureObject.setIdObject(IDObject);
pictureObject.setName(scientificName);
pictureObject.setNatureObjectType
(natureObjectType);
new Chm62edtNatureObjectPictureDomain().save
(pictureObject);
=======================
Chm62edtNatureObjectPicturePersist picture = null;
// First we find the object in database...
logger.info("Trying to find the picture...");
String sql = " ID_OBJECT='" + idObject + "' AND
NATURE_OBJECT_TYPE='" + natureObjectType + "' AND "
+
" NAME='" + name + "' AND FILE_NAME='" +
filename + "'";
List pictures = new
Chm62edtNatureObjectPictureDomain().findWhere(sql);
if (null != pictures && pictures.size() > 0) {
// ...the we remove it
logger.info("Picture found, now removing from
server...");
picture = (Chm62edtNatureObjectPicturePersist)
pictures.get(0);
int retValue = new
Chm62edtNatureObjectPictureDomain().delete(picture);
ret = (1 == retValue) ? true : false;
======================================
Now here is the problem, this code above throws the
Exception. I've tried to see the persistent state of the
picture object and is set as "current"....
I can't figure out if is necessarily do to anything else
before save() and / or delete...
Note that I use jrf 2.0 beta/JDK 1.4.1/Tomcat
4.1.18/MySQL...
Here is the stack trace:
net.sf.jrf.exceptions.ObjectHasChangedException:
at net.sf.jrf.domain.AbstractDomain.localDelete
(AbstractDomain.java:4261)
at net.sf.jrf.domain.AbstractDomain.localUpdate
(AbstractDomain.java:3970)
at net.sf.jrf.domain.AbstractDomain.update
(AbstractDomain.java:3883)
at net.sf.jrf.domain.AbstractDomain.delete
(AbstractDomain.java:4208)
at
ro.finsiel.eunis.factsheet.PicturesHelper.deletePicture
(PicturesHelper.java:86)
at org.apache.jsp.picturesUpload_jsp._jspService
(picturesUpload_jsp.java:158)
at org.apache.jasper.runtime.HttpJspBase.service
(HttpJspBase.java:137)
Thank you very much.
Logged In: YES
user_id=418714
I finally figure it out... it was because of the "Domain" class,
whose columns were declared incorrectly (Primary Key was
compounded and I forgot to declare it this way)...
Thanks anyways...best regards!
c.