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

Checking Username exists?

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my registrationDao I wanted a method to check if the username choice entered by the user already exists.
So I did this...






I expected StatementA to show 'false' when the username already exists in the db, but that isn't happening
Confused here (It shows 'true')
Please help me at this...
Thanks,
Vishwa
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishwanath,

You have to compare strings using LIKE keyword instead of simple '='

Regards,
 
Vishwanath Krishnamurthi
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried with



but still, the same result

Thanks,
Vishwa
 
Sheriff
Posts: 67402
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Eduards Sizovs wrote:You have to compare strings using LIKE keyword instead of simple '='


Umm, no, that's not correct. You would use like when looking for a pattern match; for exact match the = is fine
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vishwanath Murthi wrote:



The best way is to look at the sql which the hibernate generates for this query, run the same sql on the db through some client and see what result you get.
 
Vishwanath Krishnamurthi
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks all !

The problem was due to the mapping.... The database table had some two more fields that were not present in the object to be persisted. (that I think was the problem)

Anyway, I didn't need those extra fields and so altered the table structure. Now it works
 
Shiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic