Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# netnut 7/3/2006 6:37 PM
I am trying to learn more about the architecture for Cuyahoga by creating a custom module. I have run across a data problem when trying to update data twice.

The scenario is this:
1. I save the user entered data to the database (MySQL). This can be multiple rows in the table.
2. I then retrieve a subset of that data (once again this can be multiple rows) into a RadioButtonList so that a single selection can be made
3. I then resave the data setting a "flag" column in the table based on the users selection. I only therefore want to update a single row.

The problem is that NHibernate throws an error on the second save saying that it cannot update the data because "the row has been updated or deleted already", or words to that affect.

I use transactions for the 2 "saves"

I have used the Articles module as a "template" for this custom module and the "save" functions are modified versions from this module.

I am using the latest downloadable release of Cuyahoga, not the SVN version.

I haven't included any code as I am assuming this is something really simple and I am just not getting it.

Do I have to somehow flush the data before the second save?

Cheers.
# martijnb 7/4/2006 11:25 AM
Do the two saves occur in one request or in separate requests?
# netnut 7/4/2006 3:05 PM
They are 2 separate requests.

The user enters data and hits a submit button that calls a function to save that data via a transaction.

I then retrieve a subset of the original data into a radiobuttonlist where the user can make a single selection before again clicking a submit button.

That users selection is then used, via the primary key of the table (an id number) to set a bit column to true only on the selected item, via another transaction. The rest of the rows are already set to false by default. It is this second save, or to be more accurate, this update, where the error is occurring.

Cheers
# martijnb 7/4/2006 4:39 PM
Are you using versioning with timestamps? Usually, the error message you're getting has something to do with that.
# netnut 7/4/2006 4:50 PM
Please excuse my ignorance Martin, but what is "timestamp versioning"?

I am new to this whole type of architecture which is why I started "playing" with your code. It has been a great eye opener for me and rekindled the .net flame.

I do indeed have a Date Created column in the table that is of the type Timestamp.

Do I need to modify the NHibernate class map for this table or should I just get rid of the timestamp and convert this column to a DateTime Type to avoid this problem?

Cheers
# martijnb 7/5/2006 11:10 AM
Just see if you have a <timestamp> tag in your mapping files and get rid of it if you're not planning to use it.
# netnut 7/5/2006 4:50 PM
martijnbJust see if you have a <timestamp> tag in your mapping files and get rid of it if you're not planning to use it.

Thank you. Your advice was spot on! I have removed all timestamp references and everything is humming nicely.

I've got to say, my first impressions are that you folks have developed a very good platform here. The effort and more importantly, the thought and planning that have gone into Cuyahoga is commendable.

Well done!!
# martijnb 7/6/2006 3:03 AM
Thanks!

And glad that you managed to get things working.