Hi guys I have a problem with SPEL - Flexible Search, this is my error log when into my entity I click on button search:
ERROR [hybrisHTTP6] [PagingDelegateController] cannot search unknown field 'TableField(name='inStockStatus',langPK='null',type=Product)' within type Product unless you disable checking
and this is the query that I must create :
select {p.code},{p.description},{bs.uid}, (CASE WHEN ({p.onlineDate} is not null AND {p.onlineDate} > current_timestamp ) THEN 1 else 0 END)
from {Product as p join StockLevel as s on {s.productCode} = {p.code} join BaseStore2WarehouseRel as b on {b.target} = {s.warehouse} join BaseStore as bs on {bs.pk} = {b.source}}
where {bs.uid} in ('baseStorePk')
and {p.code} = '?productCode'
and {p.description} = '?description'
and {p.descriptionCics} = '?descriptionCics'
and {p.onlinedate} <= '?onlineDateFrom'
and {p.onlinedate} >= '?onlineDateTo'
and {s.inStockStatus} = '?inStockStatus'
and {p.doneBy} = '?doneBy'
and {s.outOfStockCause} = '?oosCause'
and {p.department} = '?department'
and {p.grm} = '?grm'
and in the image the report that I have create into myExtension-items-core.xml
based on Exception it's clear you are referring wrong attribute of product is "inStockStatus".
please replace with {s.inStockStatus} instead of {p.inStockStatus}
I'm trying to send logs to firebase within non-fatal issue but it does not work, and I can not see the logs in the firebase.
Thanks
var numberOfPhotoDownload = 0
var didAllPhotosDownloadSuccessfully = true
if (photosToDownloadChunks.size > 0) {
FirebaseCrashlytics.getInstance().recordException(Exception("API : Get Photos"))
FirebaseCrashlytics.getInstance().log("API : Get Photos")
for (chunck in photosToDownloadChunks){
for (photo in chunck){
numberOfPhotoDownload++
}
}
FirebaseCrashlytics.getInstance().log("Number of photos to download: $numberOfPhotoDownload")
var count = 1
for (chunck in photosToDownloadChunks){
for (photo in chunck){
FirebaseCrashlytics.getInstance().log("Photo number #${count} " + "Photo_filename: ${photo.fileName}")
count++
}
}
}
Hi I am using the below query to retrieve a list of products.
select qphgr.XPRODHRCHYGRP,qphgr.CPRODHRCHYGRP ,qphgr.CBUSN,qphgr.CSGM
from HPP.PNIGUT pnigu
,HPP.POGSRT pogsr
, HQL.QPHGRT qphgr
,HQL.QPRODT qprodt
,HPP.PGPLUT pgplu
where pogsr.CBUSN = '30'
and pogsr.CSGM IN ('CBU')
and pogsr.CORG = '25K'
and pogsr.CSUPPL = '999'
and pogsr.CRELT = 'NIG'
and pnigu.DVERSN between pogsr.DFR and pogsr.DTO
and pnigu.CBUSN = pogsr.CBUSN_REL
and pnigu.CSGM = pogsr.CSGM_REL
and pnigu.CORG = pogsr.CORG_REL
and pnigu.CSUPPL = pogsr.CSUPPL_REL
and pnigu.CBUSN = qphgr.CBUSN
and pgplu.cmod = qprodt.cmod
and pgplu.CTYP = qprodt.CTYP
and pgplu.copt = qprodt.copt
and pgplu.CHECOL = qprodt.CHECOL
and qprodt.CACTIV= 'Y'
and qprodt.CBUSN = qphgr.CBUSN
and qprodt.CSGM = qphgr.CSGM
and qprodt.CPRODHRCHYGRP = qphgr.CPRODHRCHYGRP
and pnigu.CORG=pgplu.CORG
and pnigu.CSUPPL=qprodt.CSUPPLGEN
group by qphgr.XPRODHRCHYGRP,qphgr.CPRODHRCHYGRP,qphgr.CBUSN,qphgr.CSGM,qphgr.NPRNTINGSEQPP
order by qphgr.NPRNTINGSEQPP
When I run this query in Squirrel it returns 15 rows which is right. But when I'm executing the same query from inside the application (I have used hibernate) it is returning only 14 rows in the return list! How is that possible. What's going wrong?
I have a query which updates (table1) and inserts into (table2) and returns a list of ids at the end which have been updated by the query.
When I run it from sql it runs properly.
But when I run from my code it returns the affected ids but it does not update & the rows.
Is it because I am doing it as: namedQuery.list() ??
SQL Query:
step 1: create table variable
step 2: update table1
step 3: store "Output Into" table variable; insert table variable content into table2
step 4: retrun affected rows (table variable column)
Here's the sql:
Declare #tempHistoryTable Table(
AG_TASK_ID int,Fulfillment_Request_ID int,Task_Type_ID int,Task_Status varchar(25)
,CF_System_User_ID int,Modified_By_System_User_ID int,AG_Task_Date datetime,row_version int
)
Declare #infoNeeded int,
#reviewResult int,
#researcherClass varchar(20),
#infoNeededReview int;
Update ag_task Set task_status = case when task_status = 'awaitingHitEntry' or task_status = 'Uploaded'
then task_status when (data_source = 'New_Jersey' or data_source = 'Illinois') and :action = 'Assign'
then 'sentForProcessing' else 'New' end
,db_version = case when db_version is null then 0 else db_version + 1 end
,modified_by_system_user_id = :assignedBy
,system_user_id = :assigningTo
,bpm_version = db_version
,task_type_id = case when task_type_id = #infoNeeded and :action = 'Assign'
then #reviewResult
when task_type_id = #infoNeeded and #researcherClass != 'External'
then #reviewResult
when (task_type_id = #infoNeededReview or task_type_id = #reviewResult) and #researcherClass = 'External'
then #infoNeeded
else task_type_id end
,creation_date = case when (task_type_id = #infoNeededReview or task_type_id = #reviewResult) and #researcherClass = 'External'
then getDate() else creation_date end
,task_assigned_date = case when :assigningTo is null then null else GETDATE() end
Output inserted.ag_task_id,inserted.Fulfillment_Request_ID,inserted.Task_Type_ID
,inserted.Task_Status,inserted.system_user_id
,inserted.Modified_By_System_User_ID,getdate(),inserted.row_version
Into #tempHistoryTable
Where fulfillment_request_id in (:fulfillmentRequestIds) and completion_date is null and
1 = case when data_source in ('New_Jersey', 'Illinois') and processing_date is null then 2 else 1 end
and 1 = case when :action = 'Claim' and system_user_id is not null then 2 else 1 end
and 1 = case when system_user_id is null and :assigningTo is null then 2 else 1 end
insert into AG_TASK_HISTORY (
AG_TASK_ID
,Fulfillment_Request_ID
,Task_Type_ID
,Task_Status
,CF_System_User_ID
,Modified_By_System_User_ID
,AG_Task_Date
,row_version
)
SELECT AG_TASK_ID
,Fulfillment_Request_ID
,Task_Type_ID
,Task_Status
,CF_System_User_ID
,Modified_By_System_User_ID
,AG_Task_Date
,row_version
from #tempHistoryTable
select Fulfillment_Request_ID from #tempHistoryTable
and this is how i'm calling the code:
String queryName = AgTask.class.getName () + ".claimAssignTasks";
final Query namedQuery = getNamedQuery ( queryName );
logger.debug("assigningTo: "+assigningTo);
logger.debug("assignedBy: "+assignedBy);
logger.debug("action: "+action);
logger.debug("fulfillmentRequestIdList: "+fulfillmentRequestIdList);
namedQuery.setParameterList("fulfillmentRequestIds", fulfillmentRequestIdList);
namedQuery.setParameter("assigningTo", assigningTo);
namedQuery.setParameter("assignedBy",assignedBy);
namedQuery.setParameter("action",action);
logger.debug("Query: "+namedQuery.getQueryString());
List<Integer> frIdList = new ArrayList<Integer>();
frIdList = namedQuery.list();
This is how i am running my test (which properly updates and inserts into table in my DB):
#Test
public void testclaimAssignTasks(){
transactionTemplate.execute(new TransactionCallbackWithoutResult ()
{
public void doInTransactionWithoutResult (TransactionStatus arg0)
{
Set<Integer> frIds = new HashSet<Integer>();
frIds.add(190195);
frIds.add(190257);
frIds.add(190243);
frIds.add(190205);
//java.util.List<Integer> frIdList =
java.util.List<Integer> frIdList = agTaskSearchDao.claimAssignTasks(frIds,846,846,"Reassign");
log.info("collection size: "+frIdList.size());
for(Integer fulfillmentRequestId : frIdList){
log.debug("fulfillmentRequestId: "+fulfillmentRequestId);
}
}
});
}
First off, I think putting such a complex query into the context of Hibernate/JPA is a really bad idea. If I were you I would try to analyze the sql and break it down, in order to see if this is something that could be solved much cleaner by lending from JPA/Hibernate functionality. Or maybe you'll end up scrapping the whole thing, solving the problem at hand with different methods.
That being said, if you want to execute an SQL (or HQL/JPQL) that is supposed to change the state of the database, you will need to use the method executeUpdate() of the Query interface, as opposed to list() or uniqueResult() that is used for retrieval of data only.
I am using jQuery for UI and my programming language is Java. Now I want to get remote data using an Ajax call to Java servlet and get the records from remote site in sorted order with also grand total. How can I do that?
I found many examples, but that was in PHP only. I want to implement it in Java, and I am not able to understand PHP.
Example which I found is as below.
JavaScript code
jQuery("#48remote2").jqGrid({
url:'server.php?q=2',
datatype: "json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:55, editable:true, sorttype:'int',summaryType:'count', summaryTpl : '({0}) total'},
{name:'invdate',index:'invdate', width:90, sorttype:'date', formatter:'date', datefmt:'d/m/Y'},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right", sorttype:'number',formatter:'number',summaryType:'sum'},
{name:'tax',index:'tax', width:80, align:"right",sorttype:'number',formatter:'number',summaryType:'sum'},
{name:'total',index:'total', width:80,align:"right",sorttype:'number',formatter:'number', summaryType:'sum'},
{name:'note',index:'note', width:150, sortable:false,editable:true}
],
rowNum:10,
rowList:[10,20,30],
height: 'auto',
pager: '#p48remote2',
sortname: 'invdate',
viewrecords: true,
sortorder: "desc",
caption:"Grouping with remote data",
grouping: true,
groupingView : {
groupField : ['name'],
groupColumnShow : [true],
groupText : ['<b>{0}</b>'],
groupCollapse : false,
groupOrder: ['asc'],
groupSummary : [true],
groupDataSorted : true
},
footerrow: true,
userDataOnFooter: true
});
jQuery("#48remote2").jqGrid('navGrid','#p48remote',{add:false,edit:false,del:false});
And PHP code is as below,
PHP MySQL code
examp = $_REQUEST["q"]; //Query number
$page = $_REQUEST['page']; // Get the requested page
$limit = $_REQUEST['rows']; // Get how many rows we want to have into the grid
$sidx = $_REQUEST['sidx']; // Get index row - i.e. user click to sort
$sord = $_REQUEST['sord']; // Get the direction
if(!$sidx) $sidx =1;
...
$result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
if( $count >0 ) {
$total_pages = ceil($count/$limit);
}
else {
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit; // Do not put $limit*($page - 1)
if ($start<0)
$start = 0;
$SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh." ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit;
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0; $amttot=0; $taxtot=0; $total=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$amttot += $row[amount];
$taxtot += $row[tax];
$total += $row[total];
$responce->rows[$i]['id']=$row[id];
$responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]);
$i++;
}
$responce->userdata['amount'] = $amttot;
$responce->userdata['tax'] = $taxtot;
$responce->userdata['total'] = $total;
$responce->userdata['name'] = 'Totals:';
echo json_encode($responce);
But I am not able to understand the code in PHP. How can I do that?
If I understand you correct you need include summary line in the bottom of the grid. To do this you don't need the grouping part from the posted example. The only parameters which are important in your case are:
footerrow: true,
userDataOnFooter: true
If you use both from the jqGrid options you need just calculate the sum for the columns where you need it has and include "userdata" part in the JSON which produce the servlet. See here, here and here for more information.