You might want to read the following mysql documentation.
http://dev.mysql.com/doc/refman/5.0/en/timestamp.html
The general gist of it is the TIMESTAMP data type is auto updating,
use DATETIME instead.
On 27/09/2007, at 3:20 PM, Tarun Reddy wrote:
I'm developing a site where people can submit ideas and other
people can rate them.
The problem is that when people rate the idea, the submission
timestamp on the idea gets updated as well and I have no idea why!
When a new idea is created I have the following method
public void awakeFromInsertion(EOEditingContext ec) {
setAvgRating(0.0);
setNumRatings(0);
setProposedStatus();
setSubmitDate(new NSTimestamp());
}
to set the default values as well as the submission timestamp. This
is the only method in my project that calls setSubmitDate!
However when I update or add a rating (which in turn updates the
AvgRating), the SubmitDate gets set to the current time. Below is
my SQL output from a simple update of a rating. It seems to be
doing the right thing, but the database and the app show new dates.
Any help would be greatly appreciated as I am stumped.
Thank you,
Tarun
(If you want to see this in action, go to http://
IdeasForABetterAmerica.org and create a user and change a rating on
an existing idea or comment. Don't worry.. I'm going to blow away
all the data as soon as I get closer to release.)
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Begin Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
t0.CATEGORY_NAME, t0.CATEGORY_OID, t0.CATEGORY_ORDER FROM CATEGORY
t0 ORDER BY t0.CATEGORY_ORDER ASC">
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - 6 row(s) processed
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Commit Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Begin Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
t0.CATEGORY_NAME, t0.CATEGORY_OID, t0.CATEGORY_ORDER FROM CATEGORY
t0 ORDER BY t0.CATEGORY_ORDER ASC">
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - 6 row(s) processed
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Commit Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Begin Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "UPDATE
IDEA SET AVGRATING = ? WHERE (IDEA_OID = ? AND CATEGORY_OID = ? AND
IDEADESC = ? AND IDEANAME = ? AND IDEAURL is NULL AND NUMRATINGS
= ? AND PARENT_OID is NULL AND STATUS = ? AND USER_OID = ?)"
withBindings: 1:-2.0(avgRating), 2:15(ideaOid), 3:5(categoryOid),
4:"Hellow!!!"(ideaDesc), 5:"Test politics entry"(ideaName), 6:1
(numRatings), 7:"A"(status), 8:2(userOid)>
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "UPDATE
IDEARATING SET RATING = ? WHERE (IDEARATING_OID = ? AND IDEA_OID
= ? AND RATING = ? AND USER_OID = ?)" withBindings: 1:-2(rating),
2:10(ideaRatingOid), 3:15(ideaOid), 4:-4(rating), 5:1(userOid)>
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Commit Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Begin Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
t0.AVGRATING, t0.CATEGORY_OID, t0.IDEADESC, t0.IDEANAME,
t0.IDEA_OID, t0.IDEAURL, t0.NUMRATINGS, t0.PARENT_OID, t0.STATUS,
t0.SUBMIT_DATE, t0.USER_OID FROM IDEA t0 WHERE t0.IDEA_OID = ?"
withBindings: 1:15(ideaOid)>
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - 1 row(s) processed
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Commit Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Begin Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
t0.CATEGORY_NAME, t0.CATEGORY_OID, t0.CATEGORY_ORDER FROM CATEGORY
t0 ORDER BY t0.CATEGORY_ORDER ASC">
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - 6 row(s) processed
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Commit Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Begin Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
t0.IDEA_OID, t0.IDEARATING_OID, t0.RATING, t0.USER_OID FROM
IDEARATING t0 WHERE t0.IDEARATING_OID = ?" withBindings: 1:10
(ideaRatingOid)>
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - 1 row(s) processed
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Commit Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Begin Internal Transaction
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - evaluateExpression:
<com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "SELECT
t0.AVGRATING, t0.CATEGORY_OID, t0.IDEADESC, t0.IDEANAME,
t0.IDEA_OID, t0.IDEAURL, t0.NUMRATINGS, t0.PARENT_OID, t0.STATUS,
t0.SUBMIT_DATE, t0.USER_OID FROM IDEA t0 WHERE t0.PARENT_OID = ?"
withBindings: 1:15(parentOid)>
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - 0 row(s) processed
Sep 26 23:03:19 Ideas[58094] (ERXNSLogLog4jBridge.java:44) DEBUG
NSLog - === Commit Internal Transaction
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/qdolan%
40gmail.com
This email sent to [EMAIL PROTECTED]
--
Seeya...Q
Quinton Dolan - [EMAIL PROTECTED]
Gold Coast, QLD, Australia (GMT+10)
Ph: +61 419 729 806
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]