Jump to content
Fórum Script Brasil
  • 0

http://javafree.uol.com.br/topic-895499-Usuario-não-encontrado-Login-Hibernate.html#276342


marcos_regato
 Share

Question

Estou fazendo um select usando Hibernate, e está dando erro quando vou busca um usuario no banco. Isso esta acontecendo na tela de Login.
LoginDao
 

LoginDao

    public Login getvalidarLogin(Login login ){    
                
            Session session = HibernateUtil.getSessionFactory().getCurrentSession();    
            Transaction t = session.beginTransaction();    
            try{    
                Query query = session.createQuery("from login where login_login='"+login.getLogin_login()+"' and login_senha='"+login.getLogin_senha()+"'"<img src="http://javafree.uol.com.br/forum/images/smiles/icon_wink.gif">;    
                login = (Login)query.uniqueResult();    
                t.commit();    
                    
            }catch(HibernateException e){    
                System.out.println("DEU MERDA NO VALIDAR LOGIN DAO .Erro: >>>>>>" + e.getMessage());    
            }    
            return login;    
        }    

loginBean

    public String validacaoLogin(){    
                
            login = dao.getvalidarLogin(login);    
            if(login != null){    
                login = new Login();    
                FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR, "Usuário não encontrado!","Erro no Login!"<img src="http://javafree.uol.com.br/forum/images/smiles/icon_wink.gif">);    
                return null;    
            } else {    
                    return "medico/medicoView";    
                }    
            }    
            
        
<h:form>    
<div class="container">    
    <div class="content">    
      <div class="row">    
        <div class="login-form">    
          <h2>Login</h2>    
            <fieldset>    
              <div class="clearfix">    
                Login :<h:inputText id="txt_login" value="#{loginBean.login.login_login}"/> <br />     
              </div>    
              <div class="clearfix">    
                Senha : <h:inputText id="txt_senha" value="#{loginBean.login.login_senha}"/> <br />    
              </div>    
              <h:commandButton value="ENTRAR" action="#{loginBean.validacaoLogin}" />    
            </fieldset>    
        </div>    
      </div>    
    </div>    
  </div>     
</h:form>   

    Mensagem do erro.   
    [code]  
        Hibernate:     
            select    
                login0_.id_login as id1_16_,    
                login0_.login_login as login2_16_,    
                login0_.login_senha as login3_16_,    
                login0_.tipo_usuario as tipo4_16_     
            from    
                login login0_     
            where    
                login0_.login_login='medico'     
                and login0_.login_senha='123'    
        out 12, 2015 3:45:25 AM com.sun.faces.renderkit.RenderKitUtils renderUnhandledMessages    
        INFORMAÇÕES: AVISO: FacesMessage(s) foram enfileirados, mas podem não ter sido exibidos.    
        sourceId=null[severity=(ERROR 2), summary=(Usuário não encontrado!), detail=(Erro no Login!)]    

Obrigado

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      149.9k
    • Total Posts
      646.8k
×
×
  • Create New...