In a Hibernate SQL query how do you escape ? character in the field name

Marc Johnson

This is a SQL Server DB and the developer, many years ago, made a column name for boolean values contain a ? character. Many systems access this DB, so changing this column name isn't really an option for me.

This works in native MS tools:

SELECT * FROM MyDatabase.dbo.[My Table] WHERE [Active?]= true

That same query fails in a session.createSQLQuery with Hibernate throwing an error attempting to interpret the ? inside the bracketed field name as a parameter.

I've tried backticks [Active?\]

I've tried escaping with /! [Active/!?] and vice versa !/ [Active!/?] with no effect.

I've also looked around quite a few stack overflow and web forums for other suggestions but the other things I've tried have not worked.

Is this a bug in hibernate? It seems to me that nothing in brackets should be interpretable as parameters.

The specific error is a query exception

> Expected positional parameter count: 1, actual parameters:[]

with the query string attached.

joachim-isaksson Answered it: [Active\\?] is it

Marc Johnson

@joachim-isaksson Answered it [Active\\?]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

In a Hibernate SQL query how do you escape ? character in the field name

From Dev

How do you conditionally check for an escape character?

From Dev

How do you escape a hyphen as character range in a POSIX regex

From Dev

How do you escape pipe character in bitbucket markdown?

From Dev

How safe is T-SQL after you replace the ' escape character?

From Dev

How to escape colon `:` within a native SQL query in Hibernate?

From Dev

How do you escape special characters in SQL Where clause?

From Dev

Escape $ character inside a MS SQL query in PHP

From Dev

How do you escape ' on doctrine?

From Dev

how do you escape a dot?

From Dev

SQL - How do you aggregate a field based on another field

From Dev

How do you display the Comment field in Query results?

From Dev

How to quote/escape a field name in AQL for arangodb?

From Dev

How to quote/escape a field name in AQL for arangodb?

From Dev

How do you write a SQL query to find all the rows that has a float currency value like $15.34 in a nvarchar field

From Dev

How do I escape a special Regex character?

From Dev

How to get field name dynamically in oracle pl/sql query?

From Dev

How do I escape an escape character with ANTLR 4?

From Dev

How do you do a "where in" sql query with an array data type?

From Dev

Mermaid CLI - how do you escape characters?

From Dev

How do you escape the @ symbol in jsonpath?

From Dev

How do you escape a space in Angular?

From Dev

How do you get the name field of a JSON object in Powershell if you don't know it?

From Dev

Escape field in LIKE query

From Dev

How to escape validation of a parent class field in child class in hibernate validator

From Dev

SQL literal escape character

From Dev

How do you count misspelled fields using a SQL query?

From Java

How do you show underlying SQL query in EF Core 2.0?

From Dev

How do you transpose rows into columns in a SQL query

Related Related

  1. 1

    In a Hibernate SQL query how do you escape ? character in the field name

  2. 2

    How do you conditionally check for an escape character?

  3. 3

    How do you escape a hyphen as character range in a POSIX regex

  4. 4

    How do you escape pipe character in bitbucket markdown?

  5. 5

    How safe is T-SQL after you replace the ' escape character?

  6. 6

    How to escape colon `:` within a native SQL query in Hibernate?

  7. 7

    How do you escape special characters in SQL Where clause?

  8. 8

    Escape $ character inside a MS SQL query in PHP

  9. 9

    How do you escape ' on doctrine?

  10. 10

    how do you escape a dot?

  11. 11

    SQL - How do you aggregate a field based on another field

  12. 12

    How do you display the Comment field in Query results?

  13. 13

    How to quote/escape a field name in AQL for arangodb?

  14. 14

    How to quote/escape a field name in AQL for arangodb?

  15. 15

    How do you write a SQL query to find all the rows that has a float currency value like $15.34 in a nvarchar field

  16. 16

    How do I escape a special Regex character?

  17. 17

    How to get field name dynamically in oracle pl/sql query?

  18. 18

    How do I escape an escape character with ANTLR 4?

  19. 19

    How do you do a "where in" sql query with an array data type?

  20. 20

    Mermaid CLI - how do you escape characters?

  21. 21

    How do you escape the @ symbol in jsonpath?

  22. 22

    How do you escape a space in Angular?

  23. 23

    How do you get the name field of a JSON object in Powershell if you don't know it?

  24. 24

    Escape field in LIKE query

  25. 25

    How to escape validation of a parent class field in child class in hibernate validator

  26. 26

    SQL literal escape character

  27. 27

    How do you count misspelled fields using a SQL query?

  28. 28

    How do you show underlying SQL query in EF Core 2.0?

  29. 29

    How do you transpose rows into columns in a SQL query

HotTag

Archive