Skip to content

Commit 0d16c5b

Browse files
Correction of CharArrayDataHandler set in DAO
1 parent 9cb7c18 commit 0d16c5b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.sql.Types;
2626

2727
import org.fugerit.java.core.db.daogen.ByteArrayDataHandler;
28+
import org.fugerit.java.core.db.daogen.CharArrayDataHandler;
2829
import org.fugerit.java.core.db.helpers.BlobData;
2930
import org.fugerit.java.core.db.helpers.DAOID;
3031

@@ -98,12 +99,22 @@ public Field newField(int value) {
9899
return (new IntField(value));
99100
}
100101

102+
public Field newField(ByteArrayDataHandler value) {
103+
return new BlobDataField( BlobData.valueOf( (ByteArrayDataHandler)value ) );
104+
}
105+
106+
public Field newField(CharArrayDataHandler value) {
107+
return new ClobDataField( value );
108+
}
109+
101110
public Field newField(Object value) {
102111
Field field = null;
103112
if ( value instanceof BlobData ) {
104113
field = new BlobDataField( (BlobData)value );
114+
} else if( value instanceof CharArrayDataHandler ) {
115+
field = newField( ((CharArrayDataHandler)value) );
105116
} else if( value instanceof ByteArrayDataHandler ) {
106-
field = new BlobDataField( BlobData.valueOf( (ByteArrayDataHandler)value ) );
117+
field = newField( ((ByteArrayDataHandler)value) );
107118
} else if (value instanceof DAOID) {
108119
field = this.newField( (DAOID)value );
109120
} else {
@@ -186,6 +197,27 @@ public void setField(PreparedStatement ps, int index) throws SQLException {
186197

187198
}
188199

200+
class ClobDataField extends Field {
201+
202+
public String toString() {
203+
return this.getClass().getName()+"[value:"+this.value+"]";
204+
}
205+
206+
public ClobDataField( CharArrayDataHandler value ) {
207+
this.value = value;
208+
}
209+
210+
/* (non-Javadoc)
211+
* @see it.finanze.secin.shared.dao.Field#setField(java.sql.PreparedStatement, int)
212+
*/
213+
public void setField(PreparedStatement ps, int index) throws SQLException {
214+
ps.setCharacterStream(index, this.value.toReader() );
215+
}
216+
217+
private CharArrayDataHandler value;
218+
219+
}
220+
189221
class StringField extends Field {
190222

191223
public String toString() {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.List;
2525

2626
import org.fugerit.java.core.db.daogen.ByteArrayDataHandler;
27+
import org.fugerit.java.core.db.daogen.CharArrayDataHandler;
2728
import org.fugerit.java.core.db.helpers.BlobData;
2829
import org.fugerit.java.core.db.helpers.DAOID;
2930

@@ -108,5 +109,8 @@ public void addField( ByteArrayDataHandler value) {
108109
this.addField( fieldFactory.newField( BlobData.valueOf( value) ) );
109110
}
110111

112+
public void addField( CharArrayDataHandler value) {
113+
this.addField( fieldFactory.newField( (CharArrayDataHandler)value ) );
114+
}
111115

112116
}

0 commit comments

Comments
 (0)