You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-4Lines changed: 18 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Comparison of how **non-JPA** SQL mapping (persistence) frameworks for Java (Joo
4
4
5
5
I'm not comparing performance, but rather how are these frameworks used for everyday tasks.
6
6
7
-
I prepared some common scenarios, which you typically need to implement data-centric application, and then we implemented these scenarios using various non-JPA DB layer frameworks. This project should serve
7
+
I prepared some common scenarios, which you typically need to implement data-centric application, and then I implemented these scenarios using various non-JPA DB layer frameworks. This project should serve
8
8
- as point of reference when deciding for SQL mapping framework
9
9
- as a template of common framework usage scenarios (see scenarios below)
10
10
- to document best practices of such common usages (**comments are welcomed!**)
@@ -23,6 +23,7 @@ With that conditions in respect, following frameworks were compared:
23
23
***Spring JDBCTemplate** (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jdbctemplate/JDBCDataRepositoryImpl.java))
24
24
***jOOQ** (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/jooq/JooqDataRepositoryImpl.java))
25
25
***MyBatis** (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/mybatis/MyBatisDataRepositoryImpl.java) and [mapper](src/main/resources/mybatis/mappers/DataRepositoryMapper.xml))
26
+
***EBean** (see [implementation](src/main/java/com/clevergang/dbtests/repository/impl/ebean/EBeanDataRepositoryImpl.java))
26
27
27
28
I tried to find optimal (== most readable) implementation in every framework, but comments are welcomed! There are lot of comments in the code explaining why I chose such implementation and some FIXMEs on places which I do not like, but which cannot be implemented differently or which I have troubles to improve...
28
29
@@ -57,7 +58,8 @@ Each scenario has it's implementation in the Scenarios class. See javadoc of [Sc
57
58
2. Configure PostgreSQL connection details in [application.properties](src/main/resources/application.properties)
58
59
3. Create tables and data by running [create-script.sql](sql-updates/create-script.sql)
59
60
4. Create one stored procedure by running [register_employee.sql](sql-updates/sql_functions/register_employee.sql)
60
-
5. Give the scenarios a test run by running one of the test classes and enjoy :)
61
+
5. Tests will passing when executed from gradle build. If you want tests to be passing even from your IDE, then [setup EBean enhancer for your IDE](http://ebean-orm.github.io/docs/setup/enhancement)
62
+
6. Give the scenarios a test run by running one of the test classes and enjoy :)
61
63
62
64
## Why only non-JPA?
63
65
@@ -98,12 +100,24 @@ Please note that following remarks are very subjective and does not have to nece
98
100
* Not so much usable for big queries - it's better to use native SQL (see scenario 9.)
99
101
* Weird syntax for performing batch operations (in case that you do not use UpdatableRecord). But it's not a big deal...
100
102
101
-
102
103
**MyBatis**
103
104
* Pros
104
105
* Writing SQL statements in XML mapper file feels good - it's easy to work with parameters.
105
106
* Cons
106
107
* quite a lot of files for single DAO imlementation (MyBatisDataRepositoryImpl, DataRepositoryMapper and DataRepositoryMapper.xml), though navigation is not such a big deal
107
108
* at version 3.4.0 unable to work with Java8 DateTime types (LocalDate etc.), support possible through 3rd party library (mybatis-types), see build.gradle and <typeHandlers> configuration in mybatis-config.xml
108
109
* can't run batch and non-batch operations in single SqlSession, but have to create completely new SqlSession instead (see configuration in DbTestsApplication class). Surprisingly, this does not necessarily mean that the batch and non-batch operations will be executed in different transactions (as we would expect), so at the end this is not a total drawback, but just inconvenience
109
-
* expected that localCacheScope=STATEMENT is default MyBatis behavior, which is not... I know this is questionable drawback, but it was kind of surprise for me, see mybatis-config.xml
110
+
* expected that localCacheScope=STATEMENT is default MyBatis behavior, which is not... I know this is questionable drawback, but it was kind of surprise for me, see mybatis-config.xml
111
+
112
+
**EBean**
113
+
* Pros
114
+
* Everything looks very nice - all the scenarios are implemented by very readable code
115
+
* Super simple batch operations (actually it's only about using right method :) )
116
+
* Although there are methods which make CRUD operations and Querying super simple, there are still means how to execute plain SQL and even a way how to get the basic JDBC Transaction object, which you can use for core JDBC stuff. That is really good.
117
+
* Cons
118
+
* Necessity to write the entities (I mean @Entity classes) - it would be cool to have some generator for it
119
+
* Necessity of "enhancement" of the entities - this was quite surprising for me - but actually it's basically only about right environment setup (IDE plugin and Gradle plugin) and then you don't have to think about it
120
+
* Online documentation is quite weak (as of December 1, 2016). Lot of things are hidden in videos and you have to google for details or get into JavaDocs... Hoverwer, JavaDoc is very good and I generally didn't a problem to find what I need in JavaDoc. Also the API is quite understandable... at the end weak online documentation is not such a big deal.
121
+
* Logging could be better
122
+
* Allows JPA OneToMany and ManyToOne relations modeling and possibility to "lazy fetch" these relations - actually I do not like this concept at all as it can lead to potentially very ineffective code. Per documentation and experiences of several people on internet EBean behaves better than full blown JPA implementation in this manner, but you can still be hit by the N+1 problem and all the performance traps, which lazy fetching brings...
0 commit comments