针对JPA的活动记录模式 ActiveJPA

码农软件 · 软件分类 · ORM/持久层框架 · 2019-09-24 12:13:19

软件介绍

ActiveJPA基于JPA,提供了Martin Fowler所提出的活动记录模式(Active Record pattern)的Java实现。借助于ActiveJPA,模型本身会作为DAO并与数据库交互,这样就不需要额外的代码作为数据访问层了。

ActiveJPA使用到了JPA规范,因此所有JPA的ORM实现(Hibernate、EclipseLink、OpenJPA等)都可以与ActiveJPA协同使用。

示例代码:

// Get order by id
Order order = Order.findById(12345L);

// Get all orders for a customer that are shipped
List<Order> orders = Order.where("customer_email", "dummyemail@dummy.com", "status", "shipped");

// Get all orders for the product category 'books' and paginate it
Filter filter = new Filter();
filter.setPageNo(1);
filter.setPerPage(25);
filter.addCondition(new Condition("orderItems.product.category", Operator.eq, "books");
List<Order> orders = Order.where(filter);

// Count of orders matching the filter
Long count = Order.count(filter);

// Get the first order matching the filter
Long count = Order.first("customer_email", "dummyemail@dummy.com", "status", "shipped");

// Get the unique order matching the conditions
Long count = Order.one("customer_email", "dummyemail@dummy.com", "status", "shipped");

// Dump everything
List<Order> orders = Order.all();

// Delete all orders matching the filter
Long count = Order.deleteAll(filter);

// Check if order exists with the given identifier
boolean exists = Order.exists(1234L);

// Save order
order.setBillingAmount(1000.0);
order.persist();

// Delete order
order.delete();

// Update attributes
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("billingAmount", 1000.0);
order.updateAttributes(attributes);

// Find order item by id within an order
order.collections("order_items").findById(123L);

// Search order items by filter with an order
order.collections("order_items").findById(filter);

....
....

本文地址:https://codercto.com/soft/d/15293.html

算法分析导论(第2版)(英文版)

算法分析导论(第2版)(英文版)

[美]Robert Sedgewick(罗伯特•塞奇威克)、[美]Philippe Flajolet(菲利普•弗拉若莱) / 电子工业出版社 / 2015-6 / 128.00元

《算法分析导论(第2版)(英文版)》全面介绍了算法的数学分析中所涉及的主要技术。涵盖的内容来自经典的数学课题(包括离散数学、初等实分析、组合数学),以及经典的计算机科学课题(包括算法和数据结构)。《算法分析导论(第2版)(英文版)》的重点是“平均情况”或“概率性”分析,书中也论述了“最差情况”或“复杂性”分析所需的基本数学工具。 《算法分析导论(第2版)(英文版)》第 1 版为行业内的经典著......一起来看看 《算法分析导论(第2版)(英文版)》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具