Thanks Emanuele,
I changed it now to:
// Delete any condending ads
List<ForecastContendingLineItem> toDelete = new
ArrayList<ForecastContendingLineItem>();
for(ForecastContendingLineItem temp :
_forecastItem.getForecastContendingLineItemArray()) {
toDelete.add(temp);
}
config.context().deleteObjects(toDelete);
// Now deal with the contending ads
LineItem contendingLineItem = null;
ForecastContendingLineItem relation = null;
for(Integer tempId : result.getContendingAdIds()) {
contendingLineItem =
LineItemDfpInfo.getLineItemByDfpId(config.context(), tempId);
if(contendingLineItem != null) {
relation =
config.context().newObject(ForecastContendingLineItem.class);
relation.setToForecast(_forecastItem);
relation.setToLineItem(contendingLineItem);
relation.setUsedImpressions(0L);
relation.setOsi(0L);
_forecastItem.addToForecastContendingLineItemArray(relation);
}
}
as you suggested, but I get a commit exception with a duplicate key entry.
01.08.2012 16:32:28 org.apache.cayenne.modeler.util.ModelerLogger info
INFO: *** error.
org.apache.cayenne.CayenneRuntimeException: [v.3.0.2 Jun 11 2011
09:31:18] Commit Exception
at
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1149)
at
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1060)
...
Caused by: java.sql.BatchUpdateException: Duplicate entry '1-451' for
key 'PRIMARY'
This tells me that the existing elements does not really have been
deleted. Do I need to commit changes first?
Gruß/Regards,
Tobias.
*Adternity GmbH*
Kennedydamm 1
40476 Düsseldorf
Tonhallenstraße 16
47051 Duisburg
Tel.: +49 203 298685 37
eMail: [email protected]
Web: http://www.adternity.net
Geschäftsführer: Thomas Servatius, Tobias Wolff, Jörn Mika, Henrik Basten
Amtsgericht: Düsseldorf, HRB 60031
Steuer-Nr.: DE238773677
On 8/1/12 4:23 PM, Emanuele Maiarelli wrote:
forgot to disable html formatting of email client, and it have been
formatted badly :)
List<ForecastContendingLineItem> toDelete=new
ArrayList<ForecastContendingLineItem>();
toDelete.addAll(_forecastItem.getForecastContendingLineItemArray());
for(ForecastContendingLineItem temp : toDelete) {
_forecastItem.removeFromForecastContendingLineItemArray(temp);
}
context.deleteObjects(toDelete);
Regards,