81,111
社区成员
发帖
与我相关
我的任务
分享
package goodsService;
import goods.GoodsCategory;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.hibernate.Session;
import util.HibernateSessionFactory;
public class GoodsDwr {
// 获取目录的option
public Map getCategoryNames() {
Map map = new HashMap();
Session session = HibernateSessionFactory.getSession();
List list = session.createQuery("from GoodsCategory").list();
for (Iterator it = list.iterator(); it.hasNext();) {
GoodsCategory gc = (GoodsCategory) it.next();
map.put(gc.getId(), gc.getName());
}
map.put(2, 2);
return map;
}
public static void main(String[] args) {
GoodsDwr dw = new GoodsDwr();
System.out.println(dw.getCategoryNames().size());
}
}