ObjectiveSql
1.0.0
ObjectiveSQL은 ActiveRecord 패턴을 기반으로 하는 Java의 ORM 프레임워크로, 빠른 개발과 정리, 최소한의 코드, 구성보다 관례를 장려합니다.
Class
SQL 프로그래밍의 모든 기능을 갖추고 있습니다.has_one
, has_many
및 belongs_to
) 쿼리 및 페이징 쿼리가 용이함arithmetic
, comparison
및 logical
) 작성 Preferences/Settings
-> Plugins
-> Search with "ObjectiveSql" in market
-> Install
<!-- In standalone -->
< dependency >
< groupId >com.github.braisdom</ groupId >
< artifactId >objective-sql</ artifactId >
< version >1.4.6</ version >
</ dependency >
<!-- In Spring Boot -->
< dependency >
< groupId >com.github.braisdom</ groupId >
< artifactId >objsql-springboot</ artifactId >
< version >1.3.4</ version >
</ dependency >
자세한 구성은 pom.xml을 참조하세요.
ObjectiveSQL은 아래의 다양한 데이터베이스에 대한 전체 예제를 제공합니다. IntelliJ IDEA를 사용하여 독립 실행형 프로젝트로 직접 열 수 있습니다. 실제로 이는 단순한 예가 아니라 다양한 데이터베이스에서 ObjectiveSQL의 단위 테스트이기도 합니다.
구성 없이 실행하려면 다음을 시도해 보세요. SQLite
기타: MySQL, Oracle, MS SQL Server, PostgreSQL, Spring Boot
주석을 사용하여 JavaBean만 정의합니다.
@ 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 . create ( newMember );
Member . create ( new Member []{ newMember1 , newMember2 , newMember3 }, false );
Member . update ( 1L , newMember , true );
Member . update ( "name = 'Smith => Jackson'" , "name = ?" , "Alice" );
Member . destroy ( 1L );
Member . destroy ( "name = ?" , "Mary" );
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 );
PagedList < Member > members = Member . pagedQueryAll ( page , Member . HAS_MANY_ORDERS );
Member . queryAll ( Member . HAS_MANY_ORDERS );
Member . queryByPrimary ( 1 , Member . HAS_MANY_ORDERS );
Member . queryByName ( "demo" , Member . HAS_MANY_ORDERS );
...
Order . Table orderTable = Order . asTable ();
Select select = new Select ();
// In ObjectiveSQL, Java operator can be overloaded
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 );
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 `