Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ccleve committed Nov 10, 2022
2 parents d885147 + 145947e commit 1460aa4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Here's the Maven dependency:
<dependency>
<groupId>com.dieselpoint</groupId>
<artifactId>norm</artifactId>
<version>0.8.5</version>
<version>1.0.5</version>
</dependency>
```

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/dieselpoint/norm/sqlmakers/StandardPojoInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -297,6 +298,12 @@ public void putValue(Object pojo, String name, Object value, boolean ignoreIfMis

if (prop.writeMethod != null) {
try {
if (value instanceof BigInteger && prop.writeMethod.getParameterCount() >= 1) {
Class type = prop.writeMethod.getParameterTypes()[0];
if (type.equals(Long.TYPE) || type.equals(Long.class)) {
value = ((BigInteger) value).longValue();
}
}
prop.writeMethod.invoke(pojo, value);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new DbException("Could not write value into pojo. Property: " + prop.name + " method: "
Expand All @@ -308,6 +315,11 @@ public void putValue(Object pojo, String name, Object value, boolean ignoreIfMis

if (prop.field != null) {
try {
if (value instanceof BigInteger) {
if (prop.field.getType().equals(Long.TYPE) || prop.field.getType().equals(Long.class)) {
value = ((BigInteger) value).longValue();
}
}
prop.field.set(pojo, value);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new DbException(
Expand Down

0 comments on commit 1460aa4

Please sign in to comment.