Skip to content

Commit 46b0b8c

Browse files
Better handling of dao Object Field in case of java.util.Date (converted
to java.sql.Timestamp).
1 parent 0d16c5b commit 46b0b8c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

fj-core/src/main/java/org/fugerit/java/core/db/dao/FieldFactory.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,17 @@ public ObjectField(Object value) {
169169
* @see it.finanze.secin.shared.dao.Field#setField(java.sql.PreparedStatement, int)
170170
*/
171171
public void setField(PreparedStatement ps, int index) throws SQLException {
172-
ps.setObject(index, this.value);
172+
if ( this.value == null ) {
173+
ps.setObject(index, this.value);
174+
} else if ( this.value instanceof java.sql.Date ) {
175+
ps.setDate(index, ((java.sql.Date)this.value));
176+
} else if ( this.value instanceof java.sql.Timestamp ) {
177+
ps.setTimestamp(index, ((java.sql.Timestamp)this.value));
178+
} else if ( this.value instanceof java.util.Date ) {
179+
ps.setTimestamp(index, new java.sql.Timestamp( ((java.util.Date)this.value).getTime() ) );
180+
} else {
181+
ps.setObject(index, this.value);
182+
}
173183
}
174184

175185
private Object value;

fj-core/src/main/java/org/fugerit/java/core/db/daogen/SelectHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class SelectHelper extends QueryHelper {
2525

2626
public static final String COMPARE_LT_EQUAL = " <= ";
2727

28+
public static final String COMPARE_GT_EQUAL = " >= ";
29+
2830
public static final String ORDER_ASC = "ASC";
2931

3032
public static final String ORDER_DESC = "DESC";

0 commit comments

Comments
 (0)