reset password
Author Message
Pallavi0205
Posts: 30
Posted 09:46 May 13, 2010 |

when we do edit it will be new entry in the database as it will be next revision, but when I do edit the values just overwrite the previous one, it's not entered as new entry.

I had taken revsionno and pageid as primary key. Can anyone help me in that?

 

 

CS320stu08
Posts: 22
Posted 10:10 May 13, 2010 |

I have done exactly same as you did. when I update and try to see in pgaAdmin in the revisions table by refreshing, it do not show. But when when I close the revisions table in pgaAdmin and again open it, it shows the revision added. Make sure that you increase your revision number everytime you add a new revision. May be this helps. 

Pallavi0205
Posts: 30
Posted 10:15 May 13, 2010 |

My revision is added to the database but it's overwriting the previous one. which means if my initial entry is revision2 in database then after doing edit my entry is revision3 but it's overwriting revision2 not added as seperate entry.

CS320stu08
Posts: 22
Posted 10:36 May 13, 2010 |

Have you done your mapping like below for composite id

                                      <composite-id>

                                               <key-many-to-one name="page" class="Page"/>

                                               <key-property name="revision" />
                                       </composite-id>
 
Try just using save instead of saveorupdate in dao implemenation. I think its mapping problem. Is your pageid created by database itself or you explicitly create your pageid. 
Pallavi0205
Posts: 30
Posted 10:45 May 13, 2010 |

I haven't done the mapping which you mentioned. I tried with save but it's the same.

katiatkn
Posts: 16
Posted 10:58 May 13, 2010 |

you could do the following,

when you initialize the edit form, instead of send the existing revision object to the jsp page, you should create a NEW revision object.

{

Revision oldRevision = getRevisionFromDatabase();

Revision newRevision = new Revision();

newRevision.SomeProperty = oldRevision.SomeProperty;      //eg. transfer content, title and page; EXCEPT the oldRevision.Id.
}

 

That way, when you call saveupdate method.... the

revision.Id will be empty, and dao will insert a new record instead of update an existing record.

cysun
Posts: 2935
Posted 11:21 May 13, 2010 |

Katia is right. In a Wiki, "editing" a page is to create a new revision, not "editing" a revision.

Pallavi0205
Posts: 30
Posted 11:28 May 13, 2010 |

Thanks, I got it. It's working now.