Dynamically creating a WHERE clause from a user Search criteria

I, as I am sure, have a fairly common problem, and I do not want to reinvent the wheel. I have a search form in which users can specify search criteria and type of search (AND OR Ext ..).

The form passes back the identifier associated with the column names and values. I am currently using server-side Java to glue strings into a where clause. It works in some cases, but it is clumsy, error prone and will not scale well.

Any suggestions?

Thanks,

David

+5
source share
7 answers

ORM ( Hibernate), API :   (, ) .

SQL , . , , Hibernate Criteria?


- (, AND OR, ...), , , .

.

+1

? , .

, .

, . -, , , .

+1

, . , , (), . Searcher, .

0

Hibernate API- Criteria, , , sql.

, Lucene Hibernate Search, . , .

0

, API , . , " ", .

: Squiggle-sql: http://code.google.com/p/squiggle-sql/

:

Squiggle - Java SQL SELECT. , , . , . .

0

Hibernate ORM, api. / .

jdbc, , , , ,

* from trans userid =?

, ,
   != null, ' > ? '

, , , .

0

" SQL Server 2005 Development" 7 SQL. , , . - , , SQL.

It is specific to SQL Server, but I believe that its general approach (huge, where the sentence or if / then SQL vs. dynamic) can be applied in all directions.

EDIT: I think it's worth adding ... never trust customer input, always parameterize your input before using it in SQL.

0
source

All Articles