ObjectiveSQL is an ORM framework in Java base on ActiveRecord pattern, which encourages rapid development and clean, codes with the least, and convention over configuration.
- Dynamic code generation with JSR 269 for Java API of database access
- Full Java API of database access without coding
- Object-oriented SQL programming for complex SQL in Java
@DomainModel
public class Member {
private String no;
@Queryable
private String name;
private Integer gender;
private String mobile;
private String otherInfo;
@Relation(relationType = RelationType.HAS_MANY)
private List<Order> orders;
}
Member.countAll();
Member.count("id > ?", 10);
Member.queryByPrimaryKey(11);
Member.queryFirst("id = ?", 11);
Member.query("id > ?", 8);
Member.queryAll();
...
Member.queryAll(Member.HAS_MANY_ORDERS);
Member.queryPrimary(1, Member.HAS_MANY_ORDERS);
Member.queryByName("demo", Member.HAS_MANY_ORDERS);
...
Order.Table orderTable = Order.asTable();
Select select = new Select();
select.project(sum(orderTable.amount) / sum(orderTable.quantity) * $(100) )
.from(orderTable)
.groupBy(orderTable.productId);
Generated SQL below:
SELECT SUM(order.amount) / SUM(order.quantity) * 100
FROM orders AS order GROUP BY order.produc_id
4 Guides/中文
If you are using Maven just add the following dependency to your pom.xml:
<dependency>
<groupId>com.github.braisdom</groupId>
<artifactId>objective-sql</artifactId>
<version>1.3.7</version>
</dependency>
Installing IntelliJ Plugin: Preferences/Settings -> Plugins -> Search with "ObjectiveSql" in market -> Install