我试图创建一个由只返回字符串(名称)和整数(id)的查询组成的值代理(BrowserDetailItem)。
SERVER 代码(每个类在不同的文件中)
public class BrowserDetailItem {
private String name;
private Integer id;
public static EntityManager entityManager() {
return (new UnitPersistence()).get();
}
BrowserDetailItem() {
}
BrowserDetailItem(String name, Integer id) {
this.name = name;
this.id = id;
}
public String getName() {
if (name == null)
return "";
else
return name;
}
public Integer getId() {
if (id == null)
return null;
else
return id;
}
public static List<BrowserDetailItem> getBrowserFilterList() {
EntityManager entityManager = entityManager();
try {
List<BrowserDetailItem> tempList = new ArrayList<BrowserDetailItem>();
Query query = entityManager
.createQuery("SELECT s.name,s.id FROM Song s, Playlist p, Composer c "
+ "WHERE s.id_playlist = p.id AND c.id = p.id_composer ");
tempList = query.getResultList();
tempList.size();
return tempList;
} catch (Exception e) {
return null;
} finally {
entityManager.close();
}
}
}
public class BrowserDetailItemDAO {
public void save(BrowserDetailItem browserItem) {
}
public BrowserDetailItem findById(Integer id) {
return null;
}
}
public class BrowserDetailItemLocator extends
Locator<BrowserDetailItem, Integer> {
@Override
public BrowserDetailItem create(Class<? extends BrowserDetailItem> clazz) {
return new BrowserDetailItem();
}
@Override
public BrowserDetailItem find(Class<? extends BrowserDetailItem> clazz,
Integer id) {
return getBrowserDetailItemDao().findById(id);
}
private BrowserDetailItemDAO getBrowserDetailItemDao() {
return new BrowserDetailItemDAO();
}
@Override
public Class<BrowserDetailItem> getDomainType() {
return BrowserDetailItem.class;
}
@Override
public Integer getId(BrowserDetailItem domainObject) {
return domainObject.getId();
}
@Override
public Class<Integer> getIdType() {
return Integer.class;
}
@Override
public Object getVersion(BrowserDetailItem domainObject) {
// return domainObject.getVersion();
return null;
}
}
共享代码(每个类在不同的文件中)
@ProxyFor(value = BrowserDetailItem.class, locator = BrowserDetailItemLocator.class)
public interface BrowserDetailItemProxy extends ValueProxy {
public String getName();
public Integer getId();
}
@Service(BrowserDetailItem.class)
public interface BrowserDetailItemRequest extends RequestContext {
Request<List<BrowserDetailItemProxy>> getBrowserFilterList();
}
我根据开发人员指南和http://cleancodematters.com/2011/06/04/tutorial-gwt-request-factory-part-i/完成了所有接线
代码执行(返回查询并将结果分配给列表)直到返回 getBrowserFilterList() 然后我收到以下错误:
com.google.web.bindery.requestfactory.server.UnexpectedException:域类型 java.lang.Object[] 无法发送到客户端。
我究竟做错了什么?请帮忙