posted 13 years ago
I want to use INSERT ... ON DUPLICATE KEY UPDATE feature of MySql.
The best possible way to make use of this is to add the SQLInsert annotation to the Class.
I want o insert objects of HourOfTheDay.java to the table HourOfTheDayDaily .
The columns in my table HourOfTheDayDaily are domain,year,month,date,hour,pages,hits,volume
Where domain,year,month,date,hour will form the composite primary key of the table.
My object HourOfTheDay.java has a property called name which is a reference to this composite id object. pages,hits,volume are other properties of the class itself
HourOfTheDay.name refers to ChronoStatisticalContextHour which has the properties domain,year,month,date,hour
In the ON DUPLICATE KEY UPDATE I want to change the values of pages,hits,volume in the table HourOfTheDayDaily to
pages = pages + HourOfTheDay.pages
hits= hits+ HourOfTheDay.hits
volume = volume + HourOfTheDay.volume
That is if the record with the given key already exist add the properties pages,hits,volume of the object HourOfTheDay
to the current column values columns pages,hits,volume of the table HourOfTheDayDaily
How is it possible to define this using SQLInsert annotation ?. Is it not possible via SQLInsert ?.
If not is there any way to achieve this with out writing a stored procedure.
I just want to know is there any body call my bean's Getter and Setter methods with "Please" in front - My favorite quip from Bugzilla