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 7065451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:57:28+00:00 2026-05-28T04:57:28+00:00

I’m pretty much completely new to the world of computer programming, so it’s been

  • 0

I’m pretty much completely new to the world of computer programming, so it’s been something of a struggle getting a really in depth understanding of many concepts. Right now, I’m working on a project in which we are implementing Spring MVC. The first step in the project is to make a login page for a website. I’ve tried modelling mine after one that we did in class, but I can’t seem to get past the following error in my web browser:

Unsupported auto value type java.lang.String for field injuryReports.Login.userName

Here is my Login entity class:

package injuryReports;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
public class Login implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id @GeneratedValue
    private String userName;
    private String password;
    private int userId;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public Login() {
    }

    public Login(String userName, String password) {
        super();
        this.userName = userName;
        this.password = password;
    }

    public Login(int userId, String userName2, String password2) {
        this.userId = userId;
        this.userName = userName2;
        this.password = password2;
    }
}

My LoginDao Class:

package injuryReports;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author nGent
 *
 */

@Component
public class LoginDao {
    @PersistenceContext private EntityManager em;

    @Transactional
    public void persist(Login user) {
        em.persist(user);
    }

    public List<Login> getAllUsers() {
        TypedQuery<Login> query = em.createQuery(
                "Select u FROM Login u ORDER BY u.id", Login.class);
        return query.getResultList();
    }

    public Login validateLogin(String userName, String password) {
        Login login = null;
        TypedQuery<Login> query = em.createQuery(
                "Select u From Login u where u.userName = :userName " +
                " and u.password = :password", Login.class).setParameter(
                "userName", userName).setParameter("password", password);
        try {
            login = query.getSingleResult();
        }
        catch (Exception e) {
            //TODO: Handle Exception
        }
        return login;
    }
}

And my LoginController class:

package injuryReports;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class LoginController {

    @Autowired
    private LoginDao loginDao;

    @RequestMapping(value = "/user", method = {RequestMethod.POST})
    public ModelAndView userEntry(HttpServletRequest request) {
        String userName = request.getParameter("userName");
        String password = request.getParameter("password");

        if (userName != "" && password != "") {
            loginDao.persist(new Login(userName, password));
        }

        return new ModelAndView("logon.jsp", "loginDao", loginDao);
    }

    @RequestMapping(value = "/login")
    public ModelAndView login(HttpServletRequest request) {
        String userName = request.getParameter("userName");
        String password = request.getParameter("password");
        String page = "login.jsp";

        if (userName != "" && password != "") {
            try {
                Login login = loginDao.validateLogin(userName, password);
                if (login != null) {
                    request.getSession().setAttribute("UserId", login.getUserId());
                    page = "login.jsp";
                }
            }
            catch (Exception e) {
                //TODO: Handle Exception
            }
        }
        return new ModelAndView(page, getDaos());
    }

    @RequestMapping(value = "/logon", method = {RequestMethod.GET})
    public ModelAndView logon(HttpServletRequest request) {
        //int userId = (Integer) request.getSession().getAttribute("userId");
        //request.getSession().setAttribute("UserID", userId);
        return new ModelAndView("logon.jsp", getDaos());
    }

    public Map<String, Object> getDaos() {
        Map<String, Object> models = new HashMap<String, Object>();
        models.put("loginDao", loginDao);
        return models;
    }
}

Sorry this is a bit long- I wanted to provide as much information as possible. I’d really appreciate any help!

  • 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-28T04:57:29+00:00Added an answer on May 28, 2026 at 4:57 am

    You cannot use @GeneratedValue on String property. It uses database sequences or AUTOINCREMENT features depending on the underlying database engine.

    Either remove this annotation:

    @Id
    private String userName;
    

    or use integer/long for id:

    @Id @GeneratedValue
    private int userId;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.