OSChina 7-4(7月份第4周) 期推荐的开源软件是ActiveJDBC。ActiveJDBC 是一个快速和轻量级的 Java 的 ORM 小型框架,语法简单易于理解,同时支持多数据库链接。ActiveJDBC 采用Apache License 2.0 授权。
ActiveJDBC 的文档非常完善。基于以下原则设计:
- 惯例重于配置(无配置)
- 拥有 SQL 知识就足够了
- 轻量级而且直观的代码
- 无会话
- 无持久层管理
- 无 proxying
下面是一个简单的 Model 类:
public class Main { public static void main(String[] args) { new DB("corporation").open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test", "root", "p@ssw0rd"); new DB("university").open("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:1521:xe", "activejdbc", "activejdbc"); Employee.deleteAll(); Student.deleteAll(); Employee.createIt("first_name", "John", "last_name", "Doe"); Employee.createIt("first_name", "Jane", "last_name", "Smith"); Student.createIt("first_name", "Mike", "last_name", "Myers"); Student.createIt("first_name", "Steven", "last_name", "Spielberg"); System.out.println("*** Employees ***"); Employee.findAll().dump(); System.out.println("*** Students ***"); Student.findAll().dump(); new DB("corporation").close(); new DB("university").close(); } }
如果你在使用Maven,添加这些到你的pom中:
<pluginRepositories> <pluginRepository> <id>ipsolutionsdev-plugin-snapshots</id> <name>IP Solutions Dev Snapshot Repo</name> <layout>default</layout> <url>http://ipsolutionsdev.com/snapshots/</url> <snapshots> <enabled>true</enabled> <checksumPolicy>warn</checksumPolicy> <updatePolicy>always</updatePolicy> </snapshots> </pluginRepository> </pluginRepositories> <repositories> <repository> <id>ipsolutionsdev-snapshots</id> <name>IP Solutions Dev Snapshot Repo</name> <layout>default</layout> <url>http://ipsolutionsdev.com/snapshots/</url> <snapshots> <enabled>true</enabled> <checksumPolicy>warn</checksumPolicy> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories>
如果你没有使用Maven,可通过该URL下载: http://ipsolutionsdev.com/snapshots/activejdbc/
更多关于ActiveJDBC的详细信息,或者下载地址请点这里
本站文章除注明转载外,均为本站原创或编译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区
转载请注明:文章转载自: 开源中国社区 [ http://www.oschina.net]
本文标题:OSChina 7-4 期推荐 小型ORM框架 ActiveJDBC
本文地址: http://www.oschina.net/news/20027/oschina-activejdbc-weekly-recommended-opensource-software
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区
转载请注明:文章转载自: 开源中国社区 [ http://www.oschina.net]
本文标题:OSChina 7-4 期推荐 小型ORM框架 ActiveJDBC
本文地址: http://www.oschina.net/news/20027/oschina-activejdbc-weekly-recommended-opensource-software