• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Custom API  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to design a rest API for looking up employees. The input would be a single string for multiple values (firstName, LastName, locations, etc.). The tricky part is we are not gonna create individual search field for each search criteria like one for field for FirstName, one for lastName and so on. All 7 search criteria will be entered in a single String.

For example, if the enter George, we should get all the employees whose first name is George. Basically we should spontaneously look up each word entered by user in database in all 7 columns(first name, last name, location, role, etc) and return the result set to UI. So If enter George Virginia, we should look up George in all 7 columns and also Virginia in all 7 columns in database and return the result set. It's exactly like the way that Google search box works! Again we have 7 search criteria and I need to apply the same logic for all search criteria.

The stack of technologies is Spring 5, JDBCTemplate and oracle.

My question is what is the best practice to design these kind of custom APIs? I need to implement it as efficient & fast as possible
 
Bartender
Posts: 1120
38
IBM DB2 Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at JPA repository documentation.It should fit well with your requirements.
 
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm all for jpa repositories, but why would this meet his requirements?
I'm not so sure you can use jpa to search the whole db, or table in your case, for a single value.
Have a look at the anywhereindb project though
With jpa you could do it in one querry but you wil still need to channel the columns in or statements.

 
Daniel Demesmaecker
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Amin Saberi wrote:
My question is what is the best practice to design these kind of custom APIs? I need to implement it as efficient & fast as possible


lol... My guess is that efficient & fast and this design shouldn't be in the same sentence, it makes no sence to me why you would want to create something like this.
It will give you tons of records you don't need. Let's say you want everyone who's firstname is george and you search for like %george% in all your columns.
In you're db you have 10.000 people who live in Georgetown. Do you really wan't your db to return thoose values?
 
Amin Saberi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:

Amin Saberi wrote:
My question is what is the best practice to design these kind of custom APIs? I need to implement it as efficient & fast as possible


lol... My guess is that efficient & fast and this design shouldn't be in the same sentence, it makes no sence to me why you would want to create something like this.
It will give you tons of records you don't need. Let's say you want everyone who's firstname is george and you search for like %george% in all your columns.
In you're db you have 10.000 people who live in Georgetown. Do you really wan't your db to return thoose values?



This is the requirement by the management. In fact the number of employees is 250,000. Eventually I pushed the target table to oracle in memory. So right now we are in a good shape. we get the result set in less 400 milliseconds.
 
You got style baby! More than this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!