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 int Index(String[] match,String keyword){ int m=0; keyword=keyword+1; match[m]=match[m]+1; System.out.println(match:+match[m]); System.out.println(keyword:+keyword); System.out.println(match[m].equals(keyword)); while(!(match[m].equals()) &&
private void setDefaultResponsePageIfNecessary() { if(!continueToOriginalDestination()) { if(session.getRoles().equals(ROLE_ADMIN)){ setResponsePage(SearchForCapacity.class); System.out.println(Role for Admin: + session.getRoles()); }
private readonly ConcurrentDictionary<string, System.Drawing.Color> _colorSet; public void BuildColorSet(IList<string> colorNames, string prefix, bool forceLastToGray) {
private Context mContext; public Upload(Context context, DropboxAPI<?> api, String dropboxPath) { // We set
private Collection<Episode> episodes = new ArrayList<Episode>(); public void checkEpisodes(String string) { for(Episode episode :
org.hibernate.hql.ast.QuerySyntaxException: users is not mapped [SELECT email, id FROM users WHERE email='dsdd@dds.com' AND password='asasas']
public partial class Page1 :System.Web.UI.Page { public static LGDP.LDGPSession var1 = null; private void
private static final String KEY = qaz; private String aString; @Override public void onCreate(Bundle
private List<string> retrieveImages(string address) { System.Net.WebClient wc = new System.Net.WebClient(); List<string> imgList = new
private String gg; public void setgg(String gg) { this.gg = gg; } public String

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.