Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3678118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:18:10+00:00 2026-05-19T03:18:10+00:00

private ILogin results; public ILogin authenticate(Login login) { System.out.println(login); System.out.println(login.getEmail()); String query = SELECT

  • 0
private ILogin results;

    public ILogin authenticate(Login login) {
        System.out.println(login);
        System.out.println(login.getEmail());
        String query = "SELECT email, id FROM Login WHERE email='"
        + login.getEmail() + "' AND password='" + login.getPassword() + "'";
        results = getHibernateTemplate().find(query);
        System.out.println(results);
        return results;
    }

How do i change results = getHibernateTemplate().find(query); I get the error in this line. But i want that in ILogin type not of List type. How do i do an Type Conversion here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:18:11+00:00Added an answer on May 19, 2026 at 3:18 am

    The problem isn’t the type conversion per se – it’s that you’ve executed a query which may return multiple results, but you only want a single result.

    You probably want to check that the resulting list has exactly one value (0 means login not found; more than 1 probably means there’s a problem in your data somewhere) and then return that first value (return (ILogin) list.get(0);).

    As a slightly separate matter, you shouldn’t be including the data directly in your query like that, IMO. Use query parameters, which is pretty easy in Hibernate:

     String query = "SELECT email, id FROM Login WHERE email=? AND password=?";
     Object[] parameters = { login.getEmail(), login.getPassword() };
     List results = getHibernateTemplate().find(query, parameters);
     if (results.size() != 1) {
         // Probably throw an exception
     }
     // I'm assuming your mapping has been set up appropriately such that
     // the returned value will *be* an `ILogin`.
     return (ILogin) results.get(0);
    

    Finally, you almost certainly don’t want results to be an instance variable – it should probably be a local variable, as per my example above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private string _itemId; [Browsable(true), Description(Required identifier for the Item.)] public string ItemId { get
org.hibernate.hql.ast.QuerySyntaxException: users is not mapped [SELECT email, id FROM users WHERE email='dsdd@dds.com' AND password='asasas']
Im trying to consume Wcf from Android , my code private final static String
private List<string> _S3 = new List<string>(); public string S3[int index] { get { return
private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) { //cant capture my TAB? System.out.print(evt.getKeyChar()); } What is the
private string? typeOfContract { get { return (string?)ViewState[typeOfContract]; } set { ViewState[typeOfContract] = value;
private IEnumerable<string> Tables { get { yield return Foo; yield return Bar; } }
private List<String> subList; private List<List<String>> records = new ArrayList<List<String>>(); for(....){ subList = new ArrayList<String>();
Private Function GetWebDataGridOKButtonId() As String Dim ctls As ControlCollection = _ WebDataGrid1.Controls(0).Controls(0).Controls Dim btn
private Mesh mesh; private Texture texture; private SpriteBatch batch; @Override public void create() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.