Compare commits
3 Commits
ff4637535a
...
00c3ed537a
Author | SHA1 | Date | |
---|---|---|---|
00c3ed537a | |||
e5b2fba283 | |||
f0b48ba785 |
@ -5,14 +5,14 @@
|
||||
<parent>
|
||||
<artifactId>fluent-sql</artifactId>
|
||||
<groupId>group.flyfish.framework</groupId>
|
||||
<version>0.1.0</version>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>fluent-sql-annotations</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -5,15 +5,15 @@
|
||||
<parent>
|
||||
<artifactId>fluent-sql</artifactId>
|
||||
<groupId>group.flyfish.framework</groupId>
|
||||
<version>0.1.0</version>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>fluent-sql-core</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -369,7 +369,7 @@ final class SQLImpl extends ConcatSegment<SQLImpl> implements SQLOperations, Pre
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Integer> execute() {
|
||||
public Mono<Long> execute() {
|
||||
return SHARED_REACTIVE_OPERATIONS.execute(entity);
|
||||
}
|
||||
}
|
||||
|
@ -44,5 +44,5 @@ public interface ReactiveBoundEntitySpec<T> {
|
||||
*
|
||||
* @return 更新行数
|
||||
*/
|
||||
Mono<Integer> execute();
|
||||
Mono<Long> execute();
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package group.flyfish.fluent.operations;
|
||||
|
||||
import group.flyfish.fluent.entity.BoundSQLEntity;
|
||||
import group.flyfish.fluent.entity.DataPage;
|
||||
import group.flyfish.fluent.entity.SQLEntity;
|
||||
import org.springframework.lang.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@ -50,5 +49,5 @@ public interface ReactiveFluentSQLOperations {
|
||||
* @param entity sql实体
|
||||
* @return 更新行数
|
||||
*/
|
||||
<T> Mono<Integer> execute(BoundSQLEntity<T> entity);
|
||||
<T> Mono<Long> execute(BoundSQLEntity<T> entity);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import group.flyfish.fluent.utils.cache.LRUCache;
|
||||
import group.flyfish.fluent.utils.context.AliasComposite;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@ -27,6 +28,9 @@ import static group.flyfish.fluent.utils.sql.SqlNameUtils.wrap;
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class EntityNameUtils {
|
||||
|
||||
private static final String JPA_TABLE = "javax.persistence.Table";
|
||||
private static final String SPRING_DATA_TABLE = "org.springframework.data.relational.core.mapping.Table";
|
||||
|
||||
// SerializedLambda 反序列化缓存
|
||||
private static final Map<String, WeakReference<SerializedLambda>> FUNC_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -57,9 +61,18 @@ public final class EntityNameUtils {
|
||||
*/
|
||||
public static String getTableName(Class<?> entityClass) {
|
||||
return TABLE_CACHE.computeIfAbsent(entityClass, k -> {
|
||||
Table table = entityClass.getAnnotation(Table.class);
|
||||
if (null != table && StringUtils.hasText(table.name())) {
|
||||
return table.name();
|
||||
MergedAnnotations annotations = MergedAnnotations.from(entityClass);
|
||||
if (annotations.isPresent(JPA_TABLE)) {
|
||||
String tableName = annotations.get(JPA_TABLE).getString("name");
|
||||
if (StringUtils.hasText(tableName)) {
|
||||
return tableName;
|
||||
}
|
||||
}
|
||||
if (annotations.isPresent(SPRING_DATA_TABLE)) {
|
||||
String tableName = annotations.get(SPRING_DATA_TABLE).getString("name");
|
||||
if (StringUtils.hasText(tableName)) {
|
||||
return tableName;
|
||||
}
|
||||
}
|
||||
return wrap(SqlNameUtils.camelToUnderline(entityClass.getSimpleName()));
|
||||
});
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>fluent-sql</artifactId>
|
||||
<groupId>group.flyfish.framework</groupId>
|
||||
<version>0.1.0</version>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<description>spring boot 快速集成组件</description>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -13,8 +13,8 @@
|
||||
<artifactId>fluent-sql-spring-boot-starter</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -11,6 +11,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@ -23,11 +24,11 @@ import javax.sql.DataSource;
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
|
||||
@Import({R2dbcFluentSqlAutoConfigure.class, JdbcFluentSqlAutoConfigure.class})
|
||||
public class FluentSqlAutoConfiguration {
|
||||
|
||||
@ConditionalOnClass(DatabaseClient.class)
|
||||
@AutoConfigureAfter(R2dbcAutoConfiguration.class)
|
||||
static class R2dbcFluentSqlAutoConfigure {
|
||||
|
||||
/**
|
||||
@ -44,6 +45,7 @@ public class FluentSqlAutoConfiguration {
|
||||
}
|
||||
|
||||
@ConditionalOnClass(DataSource.class)
|
||||
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
|
||||
static class JdbcFluentSqlAutoConfigure {
|
||||
|
||||
/**
|
||||
|
@ -5,15 +5,15 @@
|
||||
<parent>
|
||||
<artifactId>fluent-sql</artifactId>
|
||||
<groupId>group.flyfish.framework</groupId>
|
||||
<version>0.1.0</version>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>fluent-sql-spring</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -49,7 +49,6 @@
|
||||
<dependency>
|
||||
<groupId>io.asyncer</groupId>
|
||||
<artifactId>r2dbc-mysql</artifactId>
|
||||
<version>0.9.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package group.flyfish.fluent.mapping;
|
||||
|
||||
import io.r2dbc.spi.ColumnMetadata;
|
||||
import io.r2dbc.spi.Row;
|
||||
import io.r2dbc.spi.RowMetadata;
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
@ -48,7 +49,8 @@ public class ReactiveSQLMappedRowMapper<T> implements BiFunction<Row, RowMetadat
|
||||
public T apply(Row row, RowMetadata rowMetadata) {
|
||||
MappingBean<T> bean = descriptor.create();
|
||||
|
||||
for (String column : rowMetadata.getColumnNames()) {
|
||||
for (ColumnMetadata metadata : rowMetadata.getColumnMetadatas()) {
|
||||
String column = metadata.getName();
|
||||
try {
|
||||
bean.setValue(column, type -> row.get(column, type));
|
||||
} catch (Exception ex) {
|
||||
|
@ -61,7 +61,7 @@ public class R2dbcFluentSQLOperations implements ReactiveFluentSQLOperations {
|
||||
* @return 更新行数
|
||||
*/
|
||||
@Override
|
||||
public <T> Mono<Integer> execute(BoundSQLEntity<T> entity) {
|
||||
public <T> Mono<Long> execute(BoundSQLEntity<T> entity) {
|
||||
return resolve(entity).fetch().rowsUpdated();
|
||||
}
|
||||
|
||||
|
18
pom.xml
18
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>group.flyfish.framework</groupId>
|
||||
<artifactId>fluent-sql</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>0.1.0</version>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<name>fluent-sql</name>
|
||||
<description>A very fast sql generation engine using fluent-style api. Help you start your work without mybatis!</description>
|
||||
@ -35,12 +35,12 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<lombok.version>1.18.24</lombok.version>
|
||||
<jackson.version>2.17.2</jackson.version>
|
||||
<spring-boot.version>2.7.18</spring-boot.version>
|
||||
<spring.version>5.3.22</spring.version>
|
||||
<spring-boot.version>3.3.1</spring-boot.version>
|
||||
<spring.version>6.1.10</spring.version>
|
||||
</properties>
|
||||
|
||||
<!-- 开发人员信息 -->
|
||||
@ -158,6 +158,12 @@
|
||||
<version>8.0.29</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.asyncer</groupId>
|
||||
<artifactId>r2dbc-mysql</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
@ -204,7 +210,7 @@
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<version>1.7.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
|
Loading…
Reference in New Issue
Block a user