-2
我的項目是java ee web應用程序我使用hibernate,因爲我想搜索符合item_id的值,所以我編寫了搜索結果的代碼,但搜索值沒有顯示,所以如何解決此問題請幫助我。如何檢索搜索結果?
if(submitType != null && item_id != null)
{
try {
AssetsObject assets = new AssetsObject();
assets.setItem_id(item_id);
AssetsObject assets1 =assetsProvider.getAssets(assets);
item_name= assets1.getItem_name();
hardware = assets1.getHardware();
software = assets1.getSoftware();
vender = assets1.getVender();
venderTel = assets1.getVenderTel();
venderaddress= assets1.getVenderaddress();
return INPUT;
}
catch (Exception e)
{
addActionError("Not vailed item No or its not in the database");
//return INPUT;
}
我的implimenter類查詢是這個我覺得這個類的問題,你能解決這個問題嗎?
公共類AssetsProviderImpl實現AssetsProvider { 受保護的靜態記錄儀日誌= Logger.getLogger(AssetsProviderImpl.class .getName());
private HibernateProvider hibernateProvider;
public AssetsProviderImpl(HibernateProvider hibernateProvider) throws ProviderException
{
this.hibernateProvider = hibernateProvider;
log.info("AssetsProviderImpl created");
}
public AssetsObject insertAssets(AssetsObject assets) throws ProviderException
{
return (AssetsObject) hibernateProvider.save(assets);
}
public AssetsObject getAssets(AssetsObject assets) throws ProviderException
{
try
{
Session session = hibernateProvider.openSession();
try
{
Query query = (Query) session.createQuery("from org.efs.openreports.objects.AssetsObject as assets "
+ "where assets.item_id = ?");
List list1 = (List) ((org.hibernate.Query) query).list();
AssetsObject as = (AssetsObject) list1;
return as;
}
catch (HibernateException he)
{
throw he;
}
finally
{
session.close();
}
}
catch (HibernateException he)
{
throw new ProviderException(he);
}
}
>
thanx我應該學習,我編輯這個,但不顯示結果你能修復我的impliment查詢。 – user1763298