Skip to content

Commit

Permalink
Remove BigDecimal default value 0 while insert (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
sim-wangyan committed Dec 21, 2021
1 parent 9a5d0cc commit 8f0c69c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import io.xream.sqli.util.SqliJsonUtil;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.List;

/**
Expand Down Expand Up @@ -63,11 +62,11 @@ default void objectToListForCreate(List<Object> list, Object obj, List<BeanEleme
if (EnumUtil.isEnum(clz))
throw new PersistenceException(
"ENUM CAN NOT NULL, property:" + obj.getClass().getName() + "." + ele.getProperty());
if (clz == Boolean.class || clz == Integer.class || clz == Long.class
|| clz == Double.class || clz == Float.class || clz == BigDecimal.class
|| clz == Byte.class || clz == Short.class)
list.add(0);
else
// if (clz == Boolean.class || clz == Integer.class || clz == Long.class
// || clz == Double.class || clz == Float.class || clz == BigDecimal.class
// || clz == Byte.class || clz == Short.class)
// list.add(0);
// else
list.add(null);
} else {
if (ele.isJson()) {
Expand All @@ -84,7 +83,7 @@ default void objectToListForCreate(List<Object> list, Object obj, List<BeanEleme
}
} catch (Exception e) {
SqliExceptionUtil.throwRuntimeExceptionFirst(e);
throw new ParsingException(SqliExceptionUtil.getMessage(e));
throw new ParsingException(e);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,14 @@ public static PersistenceException onRollback(Object obj, Exception e, Logger l
Throwable t = SqliExceptionUtil.unwrapThrowable(e);
if (t instanceof RuntimeException)
throw (RuntimeException)t;
String msg = SqliExceptionUtil.getMessage(t);
String objStr = obj == null ? "": obj.toString();
String logStr = objStr + ", Exception: " + msg;
String eStr = objStr + ", \nException: " + msg;
logger.error(logStr);
return new PersistenceException(eStr);
return new PersistenceException(e);
}

public static QueryException onQuery(Exception e, Logger logger) {
Throwable t = SqliExceptionUtil.unwrapThrowable(e);
if (t instanceof RuntimeException)
throw (RuntimeException)t;
String msg = SqliExceptionUtil.getMessage(t);
logger.error(msg);
return new QueryException(msg);
logger.error(SqliExceptionUtil.getMessage(t));
return new QueryException(e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public class ParsingException extends RuntimeException implements Serializable {
public ParsingException(String message){
super(message);
}

public ParsingException(Throwable t) {
super(t);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ public PersistenceException(String message){
super(message);
}

public PersistenceException(Throwable t) {
super(t);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public class ProxyException extends RuntimeException {
public ProxyException(String message){
super(message);
}

public ProxyException(Throwable t) {
super(t);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ public QueryException(String message){
super(message);
}

public QueryException(Throwable t) {
super(t);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private Object toNCLOBString(Object obj) {
return new String(charArr);//FIXME UIF-8 ?
} catch (Exception e) {
SqliExceptionUtil.throwRuntimeExceptionFirst(e);
throw new PersistenceException(SqliExceptionUtil.getMessage(e));
throw new PersistenceException(e);
}finally{
if (reader !=null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean execute(String sql, Object...objs){
return nativeSupport.execute(sql, objs);
}catch (Exception e) {
SqliExceptionUtil.throwRuntimeExceptionFirst(e);
throw new PersistenceException(SqliExceptionUtil.getMessage(e));
throw new PersistenceException(e);
}finally {
removeDialectKey();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private boolean doProxy(String logTag, Callable<Boolean> callable) {
}catch (Exception e){
logger.warn("{} exception: {}" , logTag, SqliExceptionUtil.getMessage(e));
SqliExceptionUtil.throwRuntimeExceptionFirst(e);
throw new ProxyException(SqliExceptionUtil.getMessage(e));
throw new ProxyException(e);
}finally {
removeDialectKey();
long endTime = System.currentTimeMillis();
Expand Down

0 comments on commit 8f0c69c

Please sign in to comment.