• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic query creation  RSS feed

 
saakshi jain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


I have a scenario wherein with the following details:

I have a form that contains fields like firstname,middle name,lastname,dob,pin,address for Client 1.

Now this form has to cater more than one client . The problem statement is - different clients may require different number of fields to be displayed on front end. For eg: a 2nd client would want - Country field instead of pin, would not require address on the form.

Now when i submit the form , currently i have a constant query which takes values of - firstname,middle name,lastname,dob,pin,address and inserts it into database for Client 1. I want to develop a query in a way that it is created at runtime and inserts only the values that come from the form into the database..

I hope my problem is clear. Can anyone help???
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either use a dynamic query, such as building your own JPQL, or using JPA 2.0 Criteria.

Or just execute the same query and filter the resulting object data in Java.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!