Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Sep 3, 2024
1 parent 50e3336 commit 3877f69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 5 additions & 4 deletions rxlib/src/main/java/org/rx/io/EntityDatabaseImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public <T> long delete(EntityQueryLambda<T> query) {
}
query.limit(1000);
SqlMeta meta = getMeta(query.entityType);
query.setColumnMapping(columnMapping);

StringBuilder sql = new StringBuilder(meta.deleteSql);
sql.setLength(sql.length() - 2);
Expand Down Expand Up @@ -568,10 +569,10 @@ public void createMapping(Class<?>... entityTypes) {

@Override
public String tableName(Class<?> entityType) {
String n = Extends.metadata(entityType);
if (n != null) {
return n;
}
// String n = Extends.metadata(entityType);
// if (n != null) {
// return n;
// }
return tableMapping != null ? tableMapping.apply(entityType)
: entityType.getSimpleName();
}
Expand Down
10 changes: 9 additions & 1 deletion rxlib/src/main/java/org/rx/io/EntityQueryLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;
import org.rx.annotation.Metadata;
import org.rx.bean.BiTuple;
import org.rx.bean.Tuple;
import org.rx.core.Extends;
Expand Down Expand Up @@ -277,6 +278,7 @@ static <T> String resolve(ArrayList<BiTuple<Serializable, Operator, ?>> conditio
case OR:
ArrayList<BiTuple<Serializable, Operator, ?>> l = (ArrayList<BiTuple<Serializable, Operator, ?>>) condition.left;
EntityQueryLambda<T> r = (EntityQueryLambda<T>) condition.right;
r.setColumnMapping(columnMapping);
if (!b.isEmpty()) {
b.append(OP_AND);
}
Expand Down Expand Up @@ -318,7 +320,13 @@ static <T> String resolveColumnName(Object fn, BiFunc<String, String> columnMapp
}

public static final BiFunc<String, String> TO_UNDERSCORE_COLUMN_MAPPING = p -> CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, p);
public static final BiFunc<Class<?>, String> TO_UNDERSCORE_TABLE_MAPPING = p -> CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, p.getSimpleName());
public static final BiFunc<Class<?>, String> TO_UNDERSCORE_TABLE_MAPPING = t -> {
Metadata md = t.getAnnotation(Metadata.class);
if (md != null) {
return md.value();
}
return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, t.getSimpleName());
};

public static String toValueString(Object val) {
if (val == null) {
Expand Down

0 comments on commit 3877f69

Please sign in to comment.