此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【ylbai520】截止到2008-06-25 10:04:54的历史汇总数据(不包括此帖):
发帖数:6                  发帖分:520                
结贴数:5                  结贴分:420                
未结数:1                  未结分:100                
结贴率:83.33 %            结分率:80.77 %            
楼主加油

解决方案 »

  1.   

       对数据没有人为加锁,不知道在连接后@PersistenceContext(unitName = "***")
      EntityManager   em 有没有释放连接?em使用代码如下:
       /**
     * 获取所有的产品的条码
     * @return
     * @throws BaseException
     */
    public Collection<String> getAllBarcode() throws BaseException 
    {
    try {
    String sql = "select serialNO from master_serial";
    return (List<String>)em.createNativeQuery(sql).getResultList();
    } catch (Exception e) {
    throw new BaseException(e.getMessage(), e);
    }
    }
    public Collection<ProductModel> getProductsByStyleID(Integer id)
    throws BaseException {
    try {
    Style style = new Style();
    style.setId(id);
    String EQL = " from " + Product.class.getName()
    + " where style =:style ";
    Query query = em.createQuery(EQL).setParameter("style", style);
    Iterator iterator = query.getResultList().iterator();
    List list = new ArrayList();
    while (iterator.hasNext()) {
    Object entity = iterator.next();
    Object model = new ProductModel();
    converETM(model, entity);
    list.add(model);
    }
    return list;
    } catch (Exception e) {
    throw new BaseException(e.getMessage(), e);
    }
    }