Skip to content

Commit

Permalink
1.7.10
Browse files Browse the repository at this point in the history
* Refactoring `JdbcUtil.Mapper.delete/batchDelete(...)` and add
`JdbcUtil.Mapper.deleteById/batchDeleteByIds(...)`

* Change implementation in `SQLBuilder/CQLBuilder`. Input table name
won't formatted anymore.

* Improve Java Docs

* Improvements and bug fix.
  • Loading branch information
landawn committed Jul 5, 2019
1 parent 872671a commit c9375c5
Show file tree
Hide file tree
Showing 25 changed files with 1,310 additions and 937 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<classpathentry kind="src" path="schema"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/abacus-util-1.7.9.jar"/>
<classpathentry kind="lib" path="lib/abacus-util-1.7.10.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2-api-2.3.jar"/>
<classpathentry kind="lib" path="lib/log4j-api-2.3.jar"/>
<classpathentry kind="lib" path="lib/log4j-core-2.3.jar"/>
Expand Down
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
### 1.7.10

* Refactoring `JdbcUtil.Mapper.delete/batchDelete(...)` and add `JdbcUtil.Mapper.deleteById/batchDeleteByIds(...)`

* Change implementation in `SQLBuilder/CQLBuilder`. Input table name won't formatted anymore.

* Improve Java Docs

* Improvements and bug fix.


### 1.7.9

* Add `JdbcUtil.NamedQuery`.
Expand Down
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ A general programming library in Java/Android. It's easy to learn and simple to
[SQLBuilder](https://cdn.rawgit.com/landawn/AbacusUtil/master/docs/SQLBuilder_view.html),
[DynamicSQLBuilder](https://cdn.rawgit.com/landawn/AbacusUtil/master/docs/DynamicSQLBuilder_view.html),
[JdbcUtil](https://cdn.rawgit.com/landawn/AbacusUtil/master/docs/JdbcUtil_view.html),
[JdbcUtil.Dao/CrudDao](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/JdbcUtil.Dao.html),
[JdbcUtil.Dao/CrudDao](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/JdbcUtil.Dao.html),
[ConditionFactory(CF)](https://cdn.rawgit.com/landawn/AbacusUtil/master/docs/ConditionFactory_view.html)...

* ORMs for NoSQL:
Expand Down Expand Up @@ -185,33 +185,33 @@ A general programming library in Java/Android. It's easy to learn and simple to
[RemoteExecutor](https://cdn.rawgit.com/landawn/AbacusUtil/master/docs/RemoteExecutor_view.html).

* More:
[Charsets](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Charsets.html),
[Ascii](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Ascii.html),
[CalendarUnit](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/CalendarUnit.html),
[NamingPolicy](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/NamingPolicy.html),
[Properties](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Properties.html),
[PropertiesUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/PropertiesUtil.html),
[Wrapper](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Wrapper.html),
[ArrayHashSet](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/ArrayHashSet.html),
[ArrayHashMap](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/ArrayHashMap.html),
[ClassUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/ClassUtil.html),
[EscapeUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/EscapeUtil.html),
[RegExUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/RegExUtil.html),
[FilenameUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/FilenameUtil.html),
[AWSJSONUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/AWSJSONUtil.html),
[AddrUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/AddrUtil.html),
[WSSecurityUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/WSSecurityUtil.html),
[EmailUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/EmailUtil.html),
[IEEE754rUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/IEEE754rUtil.html),
[Timed](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Timed.html),
[Index](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Index.html),
[Median](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Median.html),
[f](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/f.html),
[Matth](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Matth.html),
[SafeInitializer](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/SafeInitializer.html),
[Stopwatch](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Stopwatch.html),
[RateLimiter](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/RateLimiter.html),
[Traverser](https://static.javadoc.io/com.landawn/abacus-util/1.7.9/com/landawn/abacus/util/Traverser.html)(copied from Apache commons, Google Guava...under Apache License v2) ...
[Charsets](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Charsets.html),
[Ascii](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Ascii.html),
[CalendarUnit](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/CalendarUnit.html),
[NamingPolicy](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/NamingPolicy.html),
[Properties](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Properties.html),
[PropertiesUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/PropertiesUtil.html),
[Wrapper](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Wrapper.html),
[ArrayHashSet](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/ArrayHashSet.html),
[ArrayHashMap](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/ArrayHashMap.html),
[ClassUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/ClassUtil.html),
[EscapeUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/EscapeUtil.html),
[RegExUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/RegExUtil.html),
[FilenameUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/FilenameUtil.html),
[AWSJSONUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/AWSJSONUtil.html),
[AddrUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/AddrUtil.html),
[WSSecurityUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/WSSecurityUtil.html),
[EmailUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/EmailUtil.html),
[IEEE754rUtil](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/IEEE754rUtil.html),
[Timed](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Timed.html),
[Index](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Index.html),
[Median](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Median.html),
[f](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/f.html),
[Matth](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Matth.html),
[SafeInitializer](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/SafeInitializer.html),
[Stopwatch](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Stopwatch.html),
[RateLimiter](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/RateLimiter.html),
[Traverser](https://static.javadoc.io/com.landawn/abacus-util/1.7.10/com/landawn/abacus/util/Traverser.html)(copied from Apache commons, Google Guava...under Apache License v2) ...


## Download/Installation & [Changes](https://github.com/landawn/AbacusUtil/blob/master/CHANGES.md):
Expand All @@ -221,22 +221,22 @@ A general programming library in Java/Android. It's easy to learn and simple to
* Gradle:
```gradle
// JDK 1.8 or above:
compile 'com.landawn:abacus-util:1.7.9'
compile 'com.landawn:abacus-util:1.7.10'
// JDK 1.7:
compile 'com.landawn:abacus-util-jdk7:1.7.9'
compile 'com.landawn:abacus-util-jdk7:1.7.10'
// Android (Java 1.7):
compile 'abacus-android-jdk7:1.7.9'
compile 'abacus-android-jdk7:1.7.10'
// Android-SE (Java 1.7) - small edition without Stream/Matrix/Sheet/...:
compile 'abacus-android-se-jdk7:1.7.9'
compile 'abacus-android-se-jdk7:1.7.10'
// Android (Java 1.8 or above):
compile 'com.landawn:abacus-android:1.7.9'
compile 'com.landawn:abacus-android:1.7.10'
// Android-SE (Java 1.8 or above) - small edition without Stream/Matrix/Sheet/...:
compile 'com.landawn:abacus-android-se:1.7.9'
compile 'com.landawn:abacus-android-se:1.7.10'
```
### Functional Programming:
(It's very important to learn Lambdas and Stream APIs in Java 8 to get the best user experiences with the APIs provided in AbacusUtil)
Expand Down
Binary file modified docs/Mapper.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/hello_jdbc.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 8 additions & 8 deletions samples/com/landawn/samples/abacus/Jdbc.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
import lombok.NoArgsConstructor;

/**
* All I want to do is: insert -> read -> update -> delete a record in DB table.
* CRUD: insert -> read -> update -> delete a record in DB table.
*/
public class Jdbc {
static final DataSource dataSource = JdbcUtil.createDataSource("jdbc:h2:~/test", "sa", "");
static final SQLExecutor sqlExecutor = new SQLExecutor(dataSource);
static final UserDao userDao = Dao.newInstance(UserDao.class, dataSource);
static final Mapper<User> userMapper = sqlExecutor.mapper(User.class);
static final Mapper<User, Long> userMapper = sqlExecutor.mapper(User.class);

// initialize DB schema.
static {
Expand Down Expand Up @@ -218,10 +218,10 @@ public static interface UserDao extends JdbcUtil.CrudDao<User, Long, SQLBuilder.
void insertWithId(User user) throws SQLException;

@NamedUpdate("UPDATE user SET first_name = :firstName, last_name = :lastName WHERE id = :id")
int updateFirstAndLastName(String newFirstName, String newLastName, long id) throws SQLException;
int updateFirstAndLastName(@Bind("firstName") String newFirstName, @Bind("lastName") String newLastName, @Bind("id") long id) throws SQLException;

@NamedSelect("SELECT first_name, last_name FROM user WHERE id = :id")
User getFirstAndLastNameBy(long id) throws SQLException;
User getFirstAndLastNameBy(@Bind("id") long id) throws SQLException;

@NamedSelect("SELECT id, first_name, last_name, email FROM user")
Stream<User> allUsers() throws SQLException;
Expand All @@ -239,7 +239,7 @@ public void crud_by_Dao() throws SQLException {

userDao.allUsers().map(e -> e.getFirstName() + " " + e.getLastName()).forEach(Fn.println());

userDao.delete(100L);
userDao.deleteById(100L);

// As we see, the problems here are:
// 1, No need to manually create/open and close Connection/Statement/ResultSet.
Expand All @@ -261,7 +261,7 @@ public void crud_by_Mapper() {

userMapper.update(N.asProps("firstName", "Tom", "lastName", "Hanks"), CF.eq("id", 100));

userMapper.delete(100L);
userMapper.deleteById(100L);

// How about transaction?
// See last sample.
Expand All @@ -288,7 +288,7 @@ public void test_transaction() throws SQLException {

tran = sqlExecutor.beginTransaction();
try {
userDao.delete(100L);
userDao.deleteById(100L);

// tran.commit();
} finally {
Expand All @@ -297,7 +297,7 @@ public void test_transaction() throws SQLException {

assertNotNull(userDao.gett(100L).getFirstName());

userDao.delete(100L);
userDao.deleteById(100L);
assertNull(userDao.gett(100L));

// In you're in Spring and want to use Spring transaction management,
Expand Down
2 changes: 1 addition & 1 deletion samples/com/landawn/samples/abacus/SQLExecutorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class SQLExecutorTest {
static final DataSource dataSource = JdbcUtil.createDataSource("jdbc:h2:~/test", "sa", "");
static final SQLExecutor sqlExecutor = new SQLExecutor(dataSource);
static final Mapper<User> userMapper = sqlExecutor.mapper(User.class);
static final Mapper<User, Long> userMapper = sqlExecutor.mapper(User.class);

// initialize DB schema.
static {
Expand Down
6 changes: 6 additions & 0 deletions src/com/landawn/abacus/annotation/JsonXmlField.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@
import java.lang.annotation.Target;
import java.text.DecimalFormat;

import com.landawn.abacus.annotation.Type.EnumType;

@Target({ ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonXmlField {
String name() default "";

String type() default "";

EnumType enumerated() default EnumType.STRING;

String dateFormat() default "";

String timeZone() default "";
Expand Down
41 changes: 40 additions & 1 deletion src/com/landawn/abacus/annotation/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.landawn.abacus.annotation;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

Expand All @@ -22,14 +23,52 @@
import java.lang.annotation.Target;

@Documented
@Target(METHOD)
@Target({ FIELD, METHOD })
@Retention(RUNTIME)

/**
*
* @since 0.8
*
* @author Haiyang Li
*/
public @interface Type {
/**
*
* @return
* @deprecated use {@code name} to specify attribute explicitly.
*/
@Deprecated
String value() default "";

String name() default "";

EnumType enumerated() default EnumType.STRING;

Scope scope() default Scope.ALL;

public static enum EnumType {
/** Persist enumerated type property or field as an integer. */
ORDINAL,

/** Persist enumerated type property or field as a string. */
STRING
}

public static enum Scope {
/**
* Used for json/xml/... serialization/deserialization.
*/
PARSER,

/**
* Used for database column value getter/setter.
*/
DB,

/**
* Used for all scenarios.
*/
ALL
}
}
Loading

0 comments on commit c9375c5

Please sign in to comment.