ObjectiveSql
1.0.0
ObjectiveSQL هو إطار عمل ORM في Java يعتمد على نمط ActiveRecord، الذي يشجع التطوير السريع والرموز النظيفة بأقل قدر ممكن، والتقليد بشأن التكوين.
Class
الخاص بك بقدرات مميزة تمامًا لبرمجة SQLhas_one
و has_many
و belongs_to
) والاستعلام المقسم إلى صفحاتarithmetic
comparison
logical
) باستخدام بناء جملة Java 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 `