内容简介:经过这段时间各位提交的Bug和版本的基本特性,发1.4.0 稳定版本,主要特性如下: 持久化 Member.create(newMember); Member.create(newMember, true); // Create a member without validating Member.create(...
经过这段时间各位提交的Bug和版本的基本特性,发1.4.0 稳定版本,主要特性如下:
持久化
Member.create(newMember); Member.create(newMember, true); // Create a member without validating Member.create(Member.newInstanceFrom(memberHash)); Member.create(new Member[]{newMember1, newMember2, newMember3}, false); Member.update(1L, newMember, true); // Update a member with primary key Member.update("name = 'Smith => Jackson'", "name = 'Alice'"); Member.destroy(1L); // Delete a member with primary key Member.destroy("name = 'Mary'"); // Execute SQL Member.execute(String.format("DELETE FROM %s WHERE name = 'Mary'", Member.TABLE_NAME));
事务
@Transactional public static void makeOrder(Order order, OrderLine... orderLines) throws SQLException { Order.create(order, false); OrderLine.create(orderLines, false); }
计数与查询
Member.countAll(); Member.count("id > ?", 1); Member.queryByPrimaryKey(1); Member.queryFirst("id = ?", 1); Member.query("id > ?", 1); Member.queryAll();
分页查询
Page page = Page.create(0, 10);// Create a Page instance with current page and page size PagedList<Member> members = Member.pagedQueryAll(page, Member.HAS_MANY_ORDERS);
关联查询
// Querying objects with convenient methods, and it will carry the related objects Member.queryAll(Member.HAS_MANY_ORDERS); Member.queryByPrimary(1, Member.HAS_MANY_ORDERS); Member.queryByName("demo", Member.HAS_MANY_ORDERS); ...
复杂 SQL 编程
// SQL programming with Java syntax without losing the features of SQL syntax Order.Table orderTable = Order.asTable(); Select select = new Select(); select.project(sum(orderTable.amount) / sum(orderTable.quantity) * 100) .from(orderTable) .where(orderTable.quantity > 30 && orderTable.salesAt.between($("2020-10-10 00:00:00"), $("2020-10-30 23:59:59"))) .groupBy(orderTable.productId);
-- SQL syntax is the same as Java syntax SELECT ((((SUM(`T0`.`amount` ) / SUM(`T0`.`quantity` ) )) * 100)) FROM `orders` AS `T0` WHERE ((`T0`.`quantity` > 30) AND `T0`.`sales_at` BETWEEN '2020-10-10 00:00:00' AND '2020-10-30 23:59:59') GROUP BY `T0`.`product_id`
查询更多:
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 稳定与非稳定版本软件的Docker Image构建策略
- Linux 内核版本那么多,你应该选择哪个稳定版本?
- Snowy v1.5.2 稳定版本发布
- GoLand 2018.1 稳定版发布:重大更新版本
- Chrome 71 稳定版本更新,主打“滥用广告”过滤
- MariaDB 10.1.31 发布,MariaDB 的稳定版本
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。