cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Avoid impex error message when using update in batchmode

Former Member
0 Likes
1,496

Hi all,

I have a simple impex that update "active" field of some specific cronjobs, based on job code: UPDATE CronJob[batchmode=true] ;job(code)[unique=true] ;active
;$jobCode ;false

The impex works fine when there are some data to update, otherwise it returns an error:

unresolvable:no existing item found for update

Is there a way to avoid this error message when no data are found for update?

Thanks
Giulio

View Entire Topic
Former Member
0 Likes

Giulio, tricky, but works:

 UPDATE User[batchmode=true];uid[unique=true]
 #% import de.hybris.platform.core.Registry;
 #% import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
 #% import de.hybris.platform.servicelayer.search.SearchResult;
 #% import de.hybris.platform.servicelayer.search.FlexibleSearchService;
 #%
 #% queryString = "SELECT * FROM {User} where {uid} = 'foo'";
 #% query = new FlexibleSearchQuery(queryString);
 #% result = Registry.getApplicationContext().getBean("flexibleSearchService").search(query);
 #% beforeEach: if (result.getResult().isEmpty()) line.clear();
 ;foo
Former Member
0 Likes

I actually knew this workaround but it starts to be ugly when you have multiple [unique=true] or when you want to use nested attribute (joins) ie: catalogVersion(version,catalog(id))

Former Member
0 Likes

Well, another option is to override the DefaultImportProcessorclass with your own - public Item processItemData_Impl(final ValueLine valueLine) throws ImpExException is our candidate, and then set this processor in the ImpEx file using the [processor=my.new.awesome.ImportProcessor]

The idea for customization is pretty obvious - do not update if there are no existing items and the header is UPDATE