You are right.
I have tracked it down from my application.
The problem is the GREATEST method and not the BIGINT type.
Here is the test case:
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.h2.tools.DeleteDbFiles;
public class BigintLongTest
{
public static void main(String[] args) throws Exception
{
org.h2.Driver.load();
DeleteDbFiles.execute("data", null, true);
Connection conn;
conn = DriverManager.getConnection("jdbc:h2:data/test", "sa",
"sa");
Statement stat = conn.createStatement();
String createSQL = "CREATE TABLE test (id BIGINT);";
stat.execute(createSQL);
stat.execute("insert into test values (1)");
// Returns BigDecimal
String query = "SELECT GREATEST(id, " +
((long)Integer.MAX_VALUE) + ") FROM test";
ResultSet rs = stat.executeQuery(query);
rs.next();
Object o = rs.getObject(1);
System.out.println(o.getClass().getName());
// Returns Long
String query2 = "SELECT GREATEST(id, " +
((long)Integer.MAX_VALUE + 1) + ") FROM test";
ResultSet rs2 = stat.executeQuery(query2);
rs2.next();
Object o2 = rs2.getObject(1);
System.out.println(o2.getClass().getName());
conn.close();
}
}
GREATEST returns Long for all Java-Integer values and BigDecimal for
all values greater Java-Integer range.
I don't know if that's correct or not.
MySQL returns Long for both queries.
Uli
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.