fidoandfido / blackswan

Blackswan Stock Game
Other
2 stars 0 forks source link

Non-unique data exception when logging on #15

Closed fidoandfido closed 13 years ago

fidoandfido commented 13 years ago

Exception generated when logging on:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.hibernate.NonUniqueResultException: query did not return a unique result: 2 org.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:789) org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305) net.fidoandfido.dao.UserDAO.getUserByUsername(UserDAO.java:19) net.fidoandfido.servlets.LogInServlet.doLogin(LogInServlet.java:48) net.fidoandfido.servlets.LogInServlet.doPost(LogInServlet.java:28) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.11 logs.

fidoandfido commented 13 years ago

Okay, upon investigation there are several issues here. First off, the application currently doesn't check to see if that user name is taken. This is a bug that has been fixed.

Secondly, there is an issue where by default the mySql database does not care about capilisation in varchar blobs; which is how the user name is stored. Thus a search for "foo" in the database will yield all instances of "foo", as well as "Foo", "FOO" etc. There are various workarounds for this; simplest will be to effectively ignore case sensitivity for the moment; this won't really require any changes.

fidoandfido commented 13 years ago

Fixed for the moment - there is now code in the servlet to detect if the username already exists.