Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checking Username exists?

 
Vishwanath Krishnamurthi
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
 
Eduards Sizovs
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
 
Rahul Babbar
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic