I am using IBM WCS 7 aurorab2b store.
I want to retrieve the description of a partNumber
entered by user. I am getting catentryID
= 14726 and langId
as -1. I tried the following way and I am getting javax.ejb.DuplicateKeyException
when creating instance of CatalogEntryDescriptionAccessBean
try{
String catentID = catlogBean.getCatalogEntryReferenceNumber();
long catentryID = Long.parseLong(catentID);
Integer langID = Integer.parseInt(getLanguageId());
System.out.println("catEntryID:"+catentryID);
System.out.println("langID:"+langID+"");
CatalogEntryDescriptionAccessBean catlogDescriptionBean = new CatalogEntryDescriptionAccessBean(catentryID,langID);
if(catlogDescriptionBean == null)
System.out.println("catlogDescriptionBean is null");
else
System.out.println("catlogDescriptionBean is not null");
description = catlogDescriptionBean.getShortDescription();
}
catch(Exception e){
System.out.println("EXCEPTION IN DESCRPTN");
e.printStackTrace();
}
Please note calling the constructor of access bean will Maps to a corresponding ejbCreate method in the home interface of the EJB. which means you are creating new record which already exist.
use the following way to get description using access beans:
CatalogEntryAccessBean catEntryAB = new CatalogEntryAccessBean();
catEntryAB.setInitKey_catalogEntryReferenceNumber(catentry_id);
catEntryAB.refreshCopyHelper();
CatalogEntryDescriptionAccessBean catEntryDescAB = catEntryAB.getDescription(langId);
you need yo catch suitable exceptions thrown by bean EJBs and get the description from catEntryDescAB object.
Update : 2nd way to achieve same :
String longDesc = CatalogEntryCache.getDescription(catEntryAB ,
this.commandContext.getLanguageId(), getStoreId()).getLongDescription()
please note in JSPs , WCS is using Solr to get production information , please read ProductDisplay.jsp to see the wcf services used and corresponding access/search profiles.
hope that answers your question.
Thanks
Abed