Hi Kerry.

I don't know what are Oracle doing too. At first, I thought that the 
problem was an index in the H2 database, but the GUID field has not an 
index in the Oracle. And I tested with indexes in both databases and the 
behavior is the same.

I changed the code and tested the following:

String sql = "insert into aap_user (id, email) 
values(SEQ_AAP_USER_ID.nextval, '[email protected]')";
stmt = con.createStatement();
boolean status = stmt.execute(sql, new String[]{"ID", "GUID" });
keys = stmt.getGeneratedKeys();

This code also works good in Oracle, but with H2 always it is returning 
only the ID. Also I can't use "stms.getResultSet" because always is 
returning null.

El martes, 18 de abril de 2017, 22:10:32 (UTC-3), Kerry Sainsbury escribió:
>
>
> On 19 April 2017 at 03:37, Juan Ismael Vasquez <[email protected] 
> <javascript:>> wrote:
>
>> getGeneratedKeys
>
>
> I wonder how Oracle is deciding that "GUID" RAW(16) DEFAULT RANDOM_UUID() 
> is a key -- it's doing quite a bit of introspection and making of 
> assumptions. I would've thought that H2 was behaving quite sensibly.
>
> That said, according to the Javadoc for JDBC 1.4, and I haven't tested in 
> with H2, you should be able to use this variation of 'execute' to resolve 
> your problem:
>
> boolean execute(String 
> <https://docs.oracle.com/javase/7/docs/api/java/lang/String.html> sql,
>               String 
> <https://docs.oracle.com/javase/7/docs/api/java/lang/String.html>[] 
> columnNames)
>                 throws SQLException 
> <https://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html>
>
> Those columnNames are the columns you want to access in a subsequent call to 
> 'getResultSet'. It doesn't support prepared statements, which seems a bit 
> nonsensical, and h2 might not even support it. 
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to