Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 'No such field <ID>' on H2 database #15

Open
envas opened this issue Mar 1, 2017 · 1 comment
Open

Error 'No such field <ID>' on H2 database #15

envas opened this issue Mar 1, 2017 · 1 comment

Comments

@envas
Copy link

envas commented Mar 1, 2017

Running SampleCode test on H2 database generates the following error

No such field: ID

in the call

List<Name> list = db.where("firstName=?", "John").results(Name.class);

The problem is, that H2 follows strong the ANSI definition, that unquoted column names are returned in the metadata queries in uppercase. I found discussions with the H2 author regarding metadata format here and here.

The workaround is

  1. Annotate each column with uppercase name
 @Id
 @GeneratedValue 
 @Column(name="ID")
 public long id;  
  1. For H2 you can use specific JDBC URL option database_to_upper=false. However, the database must be dropped and re-created, the workaround does not work on existing DB.

I do not know if I should classify this as a bug, anyway, the current behavior is not ANSI conform. On the other side, ANSI metadata handling probably breaks MySql or Postgres API.

No idea where to start to hunt the bug., but IMO it should be solved.

Robert

@ccleve
Copy link
Member

ccleve commented Mar 1, 2017

I'm open to suggestions on how to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants