到 Google 资讯主页   
EasyJF首页   资料   源码   软件    论坛   网站    
   使用帮助    
    该信息为本站MyRSS系统缓存内容,部分图片及附件有可能无法正常使用.easyjf.comwww.matrix.org.cn无关,不对该信息负责.通过http://www.matrix.org.cn//resource/news/pBeans_469e30be-dcc2-11db-973c-874ba584761d.html访问该信息的原始内容.
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   
pBeans 2.0发布. 使用annotations
作者: 来源:www.matrix.org.cn  发布时间:2007-03-28 09:26:15.563

pBeans 2.0版本发布了.

pBeans是一个以简单为目标的O/R Mapping工具。它根据Java Bean规则自动决定映射到数据库的字段,它on demand创建表结构,它根据最常见的情况判定对象关联,它甚至根本就没考虑事务的问题。但是,使用pBeans够简单,所以它未尝不可以成为单用户桌面应用程序的一种持久化选择。

用Groovy和pBeans结合的一段对象持久化代码如下(来自http://weblogs.java.net/pub/wlg/1299):


import net.sourceforge.pbeans.data.*
import net.sourceforge.pbeans.*

dataSource = new GenericDataSource()
dataSource.setDriverClassName("com.mysql.jdbc.Driver")
dataSource.setUrl("jdbc:mysql://localhost/test?user=test&password=test")

store = new Store(dataSource)

class User implements Persistent {
    Integer id
    String name
    Integer age
    String hometown
}

joe = new User(name:"Joe User", age:43, hometown:"Bay Minette, AL")
store.insert(joe)
newjoe = store.selectSingle(User.class, "name", "Joe User")
assert newjoe.hometown == "Bay Minette, AL"


新版本主要是改进使用了annotations.

官方站点:
http://pbeans.sourceforge.net/

 
相关文章
 
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   


EasyJF.com 2006 隐私政策 使用EasyJF前必读