Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

URLyBird Data find(String[]) method

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,

for my URLyBird project when I provide search details for the Hotel Name & Location I am to provide EXACT results from the DB. However in the Comments on the DB interface it says the find(String[]) method will return results where the DB fields BEGIN with the search criteria.

To get around this discrepancy I am planning to create an interface that extends the DB interface with a findExact(String[]) method. I will implement the find(String[]) method also but not actually use it.

Just wondering if anybody who has already passed the exam did this instead of using the predefined find(String[]) method?

cheers
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also created an extra interface (extending the given one), but I didn't add a findExact-method. I just filtered the results from the find-method in my business layer. I added an extra find-method which returns a map with record numbers and String[] pairs. So I didn't use the predefined find-method and passed
 
Cathal Mullan
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Roel, I had contemplated doing that also, it makes more sense to get back the exact results needed like you would using a proper database. But I suppose I should use the method they have defined & log my reason in my choices.txt,

cheers for your advice
 
Ranch Hand
Posts: 525
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cathal: There is no discrepancy in the specification. It is asking for
a typical "wild-card" search capability. This is consistent with saying
that a blank criteria field should match all values of that field. In the
extreme, a find() where all the criteria strings are blank should return
all the data rows. In a real example from the URLyBird hotel data,
the single search character "p" for the hotel name field, should return
7 rows; the three Palace hotels plus four Pandemonium hotels.

Jim ...
 
Cathal Mullan
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers for the reply Jim. What your saying makes sense. Don't think I'm going to risk it though. There is a must requirement that says ".. records where the name and/or location fields exactly match the values specified by the user" but the doc above the find() method says ".. A non-null value in criteria[n] matches any field value that begins with criteria[n]... ". So a subtle difference there. Just don't want to risk getting an automatic failure,

Cheers for your input though
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implemented my find-method just as Jim says: passing "p" for the hotel name field will result in 7 records returned by the find-method. Entering the "p" in the hotel name search field in the gui will result in an empty table, because there is no hotel at all that has "p" as name.
 
I brought this back from the farm where they grow the tiny ads:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic