-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
678 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
### 3.1 | ||
|
||
* Improvements and bug fix. | ||
|
||
|
||
### 2.9 | ||
|
||
* Improvements and bug fix. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.dao.CrudDaoL; | ||
import com.landawn.abacus.samples.entity.Address; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
public interface AddressDao extends CrudDaoL<Address, SQLBuilder.PSC, AddressDao> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.dao.CrudDao; | ||
import com.landawn.abacus.samples.entity.Device; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
public interface DeviceDao extends CrudDao<Device, Integer, SQLBuilder.PSC, DeviceDao> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.annotation.SqlLogEnabled; | ||
import com.landawn.abacus.jdbc.dao.CrudDao; | ||
import com.landawn.abacus.jdbc.dao.JoinEntityHelper; | ||
import com.landawn.abacus.samples.entity.Employee; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
@SqlLogEnabled | ||
public interface EmployeeDao extends CrudDao<Employee, Integer, SQLBuilder.PSC, EmployeeDao>, JoinEntityHelper<Employee, SQLBuilder.PSC, EmployeeDao> { | ||
} |
9 changes: 9 additions & 0 deletions
9
samples/com/landawn/abacus/samples/dao/EmployeeProjectDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.dao.CrudDao; | ||
import com.landawn.abacus.samples.entity.EmployeeProject; | ||
import com.landawn.abacus.util.EntityId; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
public interface EmployeeProjectDao extends CrudDao<EmployeeProject, EntityId, SQLBuilder.PSC, EmployeeProjectDao> { | ||
} |
8 changes: 8 additions & 0 deletions
8
samples/com/landawn/abacus/samples/dao/EmployeeProjectDao2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.dao.CrudDao; | ||
import com.landawn.abacus.samples.entity.EmployeeProject; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
public interface EmployeeProjectDao2 extends CrudDao<EmployeeProject, EmployeeProject, SQLBuilder.PSC, EmployeeProjectDao2> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.annotation.Config; | ||
import com.landawn.abacus.jdbc.annotation.Handler; | ||
import com.landawn.abacus.jdbc.annotation.PerfLog; | ||
import com.landawn.abacus.samples.dao.handler.UserDaoHandlerA; | ||
|
||
@PerfLog(minExecutionTimeForSql = 101, minExecutionTimeForOperation = 100) | ||
@Handler(type = UserDaoHandlerA.class) | ||
@Handler(qualifier = "handler1", filter = ".*") | ||
@Handler(qualifier = "handler2", filter = ".*", isForInvokeFromOutsideOfDaoOnly = true) | ||
@Config(addLimitForSingleQuery = true, callGenerateIdForInsertIfIdNotSet = false) | ||
public interface MyUserDaoA extends UserDao { | ||
} |
14 changes: 14 additions & 0 deletions
14
samples/com/landawn/abacus/samples/dao/NoUpdateUserDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.annotation.Cache; | ||
import com.landawn.abacus.jdbc.annotation.CacheResult; | ||
import com.landawn.abacus.jdbc.annotation.RefreshCache; | ||
import com.landawn.abacus.jdbc.dao.NoUpdateCrudDao; | ||
import com.landawn.abacus.samples.entity.User; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
@CacheResult(transfer = "none") | ||
@Cache(capacity = 1000, evictDelay = 6000) | ||
@RefreshCache | ||
public interface NoUpdateUserDao extends NoUpdateCrudDao<User, Long, SQLBuilder.PSC, NoUpdateUserDao> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.annotation.SqlLogEnabled; | ||
import com.landawn.abacus.jdbc.dao.CrudDao; | ||
import com.landawn.abacus.jdbc.dao.JoinEntityHelper; | ||
import com.landawn.abacus.samples.entity.Project; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
@SqlLogEnabled(true) | ||
public interface ProjectDao extends CrudDao<Project, Integer, SQLBuilder.PSC, ProjectDao>, JoinEntityHelper<Project, SQLBuilder.PSC, ProjectDao> { | ||
} |
14 changes: 14 additions & 0 deletions
14
samples/com/landawn/abacus/samples/dao/ReadOnlyUserDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.annotation.Cache; | ||
import com.landawn.abacus.jdbc.annotation.CacheResult; | ||
import com.landawn.abacus.jdbc.annotation.RefreshCache; | ||
import com.landawn.abacus.jdbc.dao.ReadOnlyCrudDao; | ||
import com.landawn.abacus.samples.entity.User; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
@CacheResult(transfer = "none") | ||
@Cache(capacity = 1000, evictDelay = 6000) | ||
@RefreshCache | ||
public interface ReadOnlyUserDao extends ReadOnlyCrudDao<User, Long, SQLBuilder.PSC, ReadOnlyUserDao> { | ||
} |
136 changes: 136 additions & 0 deletions
136
samples/com/landawn/abacus/samples/dao/UncheckedUserDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
import com.landawn.abacus.exception.UncheckedSQLException; | ||
import com.landawn.abacus.jdbc.Propagation; | ||
import com.landawn.abacus.jdbc.annotation.Bind; | ||
import com.landawn.abacus.jdbc.annotation.Define; | ||
import com.landawn.abacus.jdbc.annotation.DefineList; | ||
import com.landawn.abacus.jdbc.annotation.Delete; | ||
import com.landawn.abacus.jdbc.annotation.Handler; | ||
import com.landawn.abacus.jdbc.annotation.Insert; | ||
import com.landawn.abacus.jdbc.annotation.PerfLog; | ||
import com.landawn.abacus.jdbc.annotation.Select; | ||
import com.landawn.abacus.jdbc.annotation.SqlLogEnabled; | ||
import com.landawn.abacus.jdbc.annotation.Sqls; | ||
import com.landawn.abacus.jdbc.annotation.Transactional; | ||
import com.landawn.abacus.jdbc.annotation.Update; | ||
import com.landawn.abacus.jdbc.dao.OP; | ||
import com.landawn.abacus.jdbc.dao.UncheckedCrudDao; | ||
import com.landawn.abacus.jdbc.dao.UncheckedJoinEntityHelper; | ||
import com.landawn.abacus.samples.entity.User; | ||
import com.landawn.abacus.util.N; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
import com.landawn.abacus.util.stream.Stream; | ||
|
||
@PerfLog(minExecutionTimeForSql = 101, minExecutionTimeForOperation = 100) | ||
public interface UncheckedUserDao | ||
extends UncheckedCrudDao<User, Long, SQLBuilder.PSC, UncheckedUserDao>, UncheckedJoinEntityHelper<User, SQLBuilder.PSC, UncheckedUserDao> { | ||
@Insert("INSERT INTO user (id, first_name, last_name, email) VALUES (:id, :firstName, :lastName, :email)") | ||
void insertWithId(User user); | ||
|
||
@Update("UPDATE user SET first_name = :firstName, last_name = :lastName WHERE id = :id") | ||
int updateFirstAndLastName(@Bind("firstName") String newFirstName, @Bind("lastName") String newLastName, @Bind("id") long id); | ||
|
||
@SqlLogEnabled | ||
@Select("SELECT first_name, last_name FROM user WHERE id = :id") | ||
User getFirstAndLastNameBy(@Bind("id") long id); | ||
|
||
@SqlLogEnabled(false) | ||
@Select("SELECT id, first_name, last_name, email FROM user") | ||
Stream<User> allUsers(); | ||
|
||
@Insert(sql = "INSERT INTO user (id, first_name, last_name, email) VALUES (:id, :firstName, :lastName, :email)", isBatch = true) | ||
List<Long> batchInsertWithId(List<User> users); | ||
|
||
@Insert(sql = "INSERT INTO user (first_name, last_name, email) VALUES (:firstName, :lastName, :email)", isBatch = true, batchSize = 123) | ||
List<Long> batchInsertWithoutId(List<User> users); | ||
|
||
@Update(sql = "UPDATE user SET first_name = :firstName, last_name = :lastName WHERE id = :id", isBatch = true) | ||
int batchUpdate(List<User> users); | ||
|
||
@Delete(sql = "DELETE FROM user where id = :id", isBatch = true) | ||
int batchDelete(List<User> users); | ||
|
||
@Delete(sql = "DELETE FROM user where id = :id", isBatch = true, batchSize = 10000) | ||
int batchDeleteByIds(List<Long> userIds); | ||
|
||
@Delete(sql = "DELETE FROM user where id = ?", isBatch = true, batchSize = 10000) | ||
int batchDeleteByIds_1(List<Long> userIds); | ||
|
||
default int[] batchDeleteByIds_2(List<Long> userIds) throws SQLException { | ||
return prepareNamedQuery("DELETE FROM user where id = :id").addBatchParameters(userIds, long.class).batchUpdate(); | ||
} | ||
|
||
@Sqls({ "SELECT * FROM user where id >= :id", "SELECT * FROM user where id >= :id" }) | ||
default List<User> listUserByAnnoSql(long id, String... sqls) { | ||
try { | ||
return prepareNamedQuery(sqls[0]).setLong(1, id).list(User.class); | ||
} catch (SQLException e) { | ||
throw new UncheckedSQLException(e); | ||
} | ||
} | ||
|
||
@Transactional | ||
@Sqls({ "update user set first_name = ? where id = -1", "SELECT * FROM user where id >= :id" }) | ||
default List<User> listUserByAnnoSql2(String firstName, long id, String... sqls) { | ||
try { | ||
prepareQuery(sqls[0]).setString(1, firstName).update(); | ||
return prepareNamedQuery(sqls[1]).setLong(1, id).list(User.class); | ||
} catch (SQLException e) { | ||
throw new UncheckedSQLException(e); | ||
} | ||
} | ||
|
||
@Transactional(propagation = Propagation.SUPPORTS) | ||
@Sqls("DELETE from user where id = ?") | ||
default boolean delete_propagation_SUPPORTS(long id, String... sqls) { | ||
N.sleep(1001); | ||
|
||
try { | ||
return prepareQuery(sqls[0]).setLong(1, id).update() > 0; | ||
} catch (SQLException e) { | ||
throw new UncheckedSQLException(e); | ||
} | ||
} | ||
|
||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
@Handler(qualifier = "handler2") | ||
@Sqls("DELETE from user where id = ?") | ||
default boolean delete_propagation_REQUIRES_NEW(long id, String... sqls) { | ||
try { | ||
return prepareQuery(sqls[0]).setLong(1, id).update() > 0; | ||
} catch (SQLException e) { | ||
throw new UncheckedSQLException(e); | ||
} | ||
} | ||
|
||
@Delete(sql = "DELETE FROM {tableName} where id = :id") | ||
int deleteByIdWithDefine(@Define("tableName") String tableName, @Bind("id") long id); | ||
|
||
@Delete(sql = "DELETE FROM {tableName} where id = :id", isBatch = true, batchSize = 10000) | ||
int deleteByIdsWithDefine(@DefineList("tableName") List<String> tableName, List<Long> userIds); | ||
|
||
@Select(sql = "SELECT * FROM {tableName} where id = :id ORDER BY {{orderBy}}") | ||
User selectByIdWithDefine(@Define("tableName") String tableName, @Define("{{orderBy}}") String orderBy, @Bind("id") long id); | ||
|
||
@Select(sql = "SELECT * FROM {tableName} where id >= ? ORDER BY {whatever -> orderBy{{P}}") | ||
List<User> selectByIdWithDefine_2(@Define("tableName") String tableName, @Define("{whatever -> orderBy{{P}}") String orderBy, long id); | ||
|
||
@Select(sql = "SELECT * FROM {tableName} where id >= ? AND first_name != ? ORDER BY {whatever -> orderBy{{P}} LIMIT {count}") | ||
List<User> selectByIdWithDefine_3(@Define("tableName") String tableName, long id, @Define("{whatever -> orderBy{{P}}") String orderBy, | ||
@Define("{count}") long count, String firstName); | ||
|
||
@Select(sql = "SELECT * FROM {tableName} where id >= :id AND first_name != :firstName ORDER BY {whatever -> orderBy{{P}} LIMIT {count}") | ||
List<User> selectByIdWithDefine_4(@Define("tableName") String tableName, @Bind("id") long id, @Define("{whatever -> orderBy{{P}}") String orderBy, | ||
@Define("{count}") long count, @Bind("firstName") String firstName); | ||
|
||
@Select(sql = "SELECT * FROM {tableName} where id = :id ORDER BY {{orderBy}}") | ||
boolean exists(@Define("tableName") String tableName, @Define("{{orderBy}}") String orderBy, @Bind("id") long id); | ||
|
||
@Select(sql = "SELECT * FROM {tableName} where id = :id ORDER BY {{orderBy}}", op = OP.exists) | ||
boolean isThere(@Define("tableName") String tableName, @Define("{{orderBy}}") String orderBy, @Bind("id") long id) throws SQLException; | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
samples/com/landawn/abacus/samples/dao/UncheckedUserDaoL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.landawn.abacus.samples.dao; | ||
|
||
import com.landawn.abacus.jdbc.annotation.PerfLog; | ||
import com.landawn.abacus.jdbc.dao.UncheckedCrudDaoL; | ||
import com.landawn.abacus.jdbc.dao.UncheckedReadOnlyCrudJoinEntityHelper; | ||
import com.landawn.abacus.samples.entity.User; | ||
import com.landawn.abacus.util.SQLBuilder; | ||
|
||
@PerfLog(minExecutionTimeForSql = 101, minExecutionTimeForOperation = 100) | ||
public interface UncheckedUserDaoL extends UncheckedCrudDaoL<User, SQLBuilder.PSC, UncheckedUserDaoL>, | ||
UncheckedReadOnlyCrudJoinEntityHelper<User, Long, SQLBuilder.PSC, UncheckedUserDaoL> { | ||
} |
Oops, something went wrong.