Eclipse中的EJB V3.0数据库持久化 - 编程入门网
leName();
public String test() {
Catalog catalog = new Catalog(new Integer(1), "IBM developerWorks",
"IBM", "July 2006", "The Java XPath API",
"Elliotte Rusty Harold");
em.persist(catalog);
Catalog catalog2 = new Catalog(new Integer(2), "IBM developerWorks",
"IBM", "March 2009", "Use XQuery for the presentation layer",
"Brian M. Carey");
em.persist(catalog2);
Catalog catalog3 = new Catalog(new Integer(3), "IBM developerWorks",
"IBM", "April 2008", "Use XQuery from a Java environment",
"Brett McLaughlin");
em.persist(catalog3);
String retValue = "<b>A catalog entry: </b>";
List catalogEntry = em.createQuery(
"SELECT c from Catalog c where c.author=:name").setParameter(
"name", "Elliotte Rusty Harold").getResultList();
for (Iterator iter = catalogEntry.iterator(); iter.hasNext();) {
Catalog element = (Catalog) iter.next();
retValue = retValue + "<br/>" + element.getJournal() + "<br/>"
+ element.getPublisher() + "<br/>" + element.getDate()
+ "<br/>" + element.getTitle() + "<br/>"
+ element.getAuthor() + "<br/>";
}
retValue = retValue + "<b>All Titles: </b>";
List allTitles = em.createQuery("SELECT c from Catalog c")
.getResultList();
for (Iterator iter = allTitles.iterator(); iter.hasNext();) {
Catalog element = (Catalog) iter.next();
retValue = retValue + "<br/>" + element.getTitle() + "<br/>";
}
em.remove(catalog2);
retValue = retValue + "<b>All Entries after removing an entry: </b>";
List allCatalogEntries = em.createQuery("SELECT c from Catalog c")
.getResultList();
for (Iterator iter = allCatalogEntries.iterator(); iter.hasNext();) {
Catalog element = (Catalog) iter.next();
retValue = retValue + "<br/>" + element + "<br/>";
}
return retValue;
}
}
Eclipse中的EJB V3.0数据库持久化(11)时间:2011-10-16 IBM Deepak Vohra为该会话 Bean 添加一个远程和本地接口(见清单 4)。 清单 4. 会话 Bean 的远程和本地接口
创建一个测试客户端 到目前为止,我们已经创建了一个包含业务逻辑的实体 Bean 和一个封装实体 Be |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |