Database Query using Hibernate
Hi, we are working on a migration project. Currently we are using stored procedures for fetching the data which uses linked servers to fetch cross server data. Below is a query to give you some idea.
WHName = case when PO.DelWhID = 0 then 'Multiple' else (select WarehouseName from Server2.Configuration.dbo.Warehouse where WarehouseID = PO.DelWhID) end,
From Invoice IV With (NoLock),
PurchaseOrder PO With (NoLock),
Where IV.SellerUserID = @UserID
and PO.BuyerCompID = C.CompanyID
and PO.OrderID = IV.OrderID
and (@SearchTextBy = 0
or @SearchValue = ''
or (@SearchTextBy = 1 and C.CompanyName like '%' + @SearchValue + '%')
or (@SearchTextBy = 2 and PO.PONumber like '%' + @SearchValue + '%')
or (@SearchTextBy = 3 and iv.InvoiceNumber like '%' + @SearchValue + '%') ) .
Please suggest the best way to implement this using Hibernate.
Thanks in advance.