darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
447 stars 173 forks source link

Exception Thrown with Camel Cased Embedded Attributes #6

Closed cciemier closed 8 years ago

cciemier commented 8 years ago

Thank you for all of your hard work on this project -- it has proven extremely useful!

I have identified an issue where a hibernate QueryException is being thrown. I have a class with an @Embedded attribute that is camel-cased. The result is a "could not resolve property of..." error.

The reason for this error is because the field in the column data is being set to lower case. Therefore, instead of:

locomotive.locomotiveId.mark

I get:

locomotive.locomotiveid.mark

I downloaded your software, and removed "toLowerCase" in line 152 of DataTablesUtils.java:

.or(Expressions.stringOperation(Ops.STRING_CAST, entity.get(column.getData()))

The search capability started to work.

There appear to be other areas in this file where values are transformed into lower case. I have not looked closely enough to understand the implications removing these as well.

I am using QueryDSL.

Thank you for any insight, advice.

Best regards,

--Chris

darrachequesne commented 8 years ago

Hi, thanks for your feedback!

You're absolutly right, applying toLowerCase to column.getData() does not make much sense, it's the column itself which should be cast to String and then applied lower().

https://github.com/darrachequesne/spring-data-jpa-datatables/commit/ed6d7555adf6c3e06ed0f2267caaed5632f4d76d should fix that, could you confirm please?

cciemier commented 8 years ago

Hey Damien,

I have pulled the latest software from the Git repository, and confirm that you have resolved the reported issue. As an FYI, you also fixed another issue regarding case-insensitive searches. Initially, when I attempted to search on a text field, the query generated was case sensitive (since the filter was set to ‘toLowerCase’). The search failed on a Postgres database, because the column was all upper case. I looked at one of your test cases that tested this feature, and notice you are using H2 embedded. I am not sure why the test case was passing, as H2 is case sensitive. However, after this fix, everything seems to be working.

Thank you once again for all of your hard work!

--Chris

From: Damien Arrachequesne [mailto:notifications@github.com] Sent: Wednesday, March 30, 2016 7:48 PM To: darrachequesne/spring-data-jpa-datatables spring-data-jpa-datatables@noreply.github.com Cc: Ciemier, Christopher (CCIEMIER) CCIEMIER@arinc.com Subject: Re: [darrachequesne/spring-data-jpa-datatables] Exception Thrown with Camel Cased Embedded Attributes (#6)

Hi, thanks for your feedback!

You're absolutly right, applying toLowerCase to column.getData() does not make much sense, it's the column itself which should be cast to String and then applied lower().

ed6d755https://github.com/darrachequesne/spring-data-jpa-datatables/commit/ed6d7555adf6c3e06ed0f2267caaed5632f4d76d should fix that, could you confirm please?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://github.com/darrachequesne/spring-data-jpa-datatables/issues/6#issuecomment-203688261