On Tue, 2007-02-13 at 09:52 +0000, Jim Downing wrote:
> José A. Rubio wrote:
> > java.lang.IllegalArgumentException: Value for SIZE_BYTES is not an 
> > integer
> This has come up before: -
> 
> https://sourceforge.net/tracker/?func=detail&atid=119984&aid=1460754&group_id=19984
> 


You could try the patch below.

It's *really* hacky, and does two things:

1) for Integer / Decimal jdbc types, when using Oracle, it checks to see
if the column is long, and uses long values if it is, otherwise, it uses
ints.

2) in getLongColumn(), if the returned object is an Integer, then it
accepts it as valid and returns a long.

Like I say, it's a bit messy, but it gets around the immediate problem
(as tested locally in a file submission). But could do with a bit more
thought and review.

G

oracle-hack:


### Eclipse Workspace Patch 1.0
#P dspace
Index: src/org/dspace/storage/rdbms/DatabaseManager.java
===================================================================
RCS
file: /cvsroot/dspace/dspace/src/org/dspace/storage/rdbms/DatabaseManager.java,v
retrieving revision 1.40
diff -u -r1.40 DatabaseManager.java
--- src/org/dspace/storage/rdbms/DatabaseManager.java   5 Jul 2006
16:17:16 -0000  1.40
+++ src/org/dspace/storage/rdbms/DatabaseManager.java   15 Feb 2007
12:40:54 -0000
@@ -1415,7 +1415,15 @@
                 else if ((jdbctype == Types.INTEGER)
                         || (jdbctype == Types.DECIMAL))
                 {
-                    statement.setInt(count, row.getIntColumn(column));
+                    if
("oracle".equals(ConfigurationManager.getProperty("db.name")))
+                    {
+                        if (row.isLongColumn(column))
+                            statement.setLong(count,
row.getLongColumn(column));
+                        else
+                            statement.setInt(count,
row.getIntColumn(column));
+                    }
+                    else
+                        statement.setInt(count,
row.getIntColumn(column));
 
                     continue;
                 }
Index: src/org/dspace/storage/rdbms/TableRow.java
===================================================================
RCS
file: /cvsroot/dspace/dspace/src/org/dspace/storage/rdbms/TableRow.java,v
retrieving revision 1.11
diff -u -r1.11 TableRow.java
--- src/org/dspace/storage/rdbms/TableRow.java  16 Nov 2006 23:40:47
-0000   1.11
+++ src/org/dspace/storage/rdbms/TableRow.java  15 Feb 2007 12:40:54
-0000
@@ -123,6 +123,16 @@
 
         return data.get(canonicalize(column)) == NULL_OBJECT;
     }
+    
+    public boolean isLongColumn(String column)
+    {
+        String name = canonicalize(column);
+        Object value = data.get(name);
+        if (value instanceof Long)
+            return true;
+        
+        return false;
+    }
 
     /**
      * Return the integer value of column.
@@ -198,9 +208,15 @@
                     + " not present");
         }
 
+        if ((value instanceof Integer))
+        {
+            return ((Integer) value).longValue();
+        }
+        
         if (!(value instanceof Long))
         {
-            throw new IllegalArgumentException("Value is not an long");
+            throw new IllegalArgumentException("Value for " + column
+                    + " is not a long");
         }
 
         return ((Long) value).longValue(); 
 
 
This e-mail is confidential and should not be used by anyone who is not the 
original intended recipient. BioMed Central Limited does not accept liability 
for any statements made which are clearly the sender's own and not expressly 
made on behalf of BioMed Central Limited. No contracts may be concluded on 
behalf of BioMed Central Limited by means of e-mail communication. BioMed 
Central Limited Registered in England and Wales with registered number 3680030 
Registered Office Middlesex House, 34-42 Cleveland Street, London W1T 4LB

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech

Reply via email to