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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:42:05+00:00 2026-05-19T14:42:05+00:00

I am having a problem with HibernateTemplate and I don’t know where I am

  • 0

I am having a problem with HibernateTemplate and I don’t know where I am going wrong. I am using Hibernate3 and Tomcat6.
In my DAO, I have functions that try to query the database using a string and they seem to work fine. Like this

public AppUser getUserByUserName(String username){
    HibernateTemplate template=new HibernateTemplate(sessionFactory);
    try{
        List<AppUser> appList = template.find(" from AppUser as au where au.username=?", username);
        tempUser = appList.get(0);  
        return tempUser;
    } catch(Exception e){
        System.out.println("Problem in AppUserDao--get byUsername: " + e.toString());
        return null;
    }
}

Yet, when I try to query using an integer. Like:

public List<AppUser> getAllMerchants(){
    HibernateTemplate template=new HibernateTemplate(sessionFactory);
    try{
        List<AppUser> appList = template.find(" from appuser as au where au.securityLevel!=?", 112);
        if(appList.size() > 0)
            return appList;
        else
            return null;
    } catch(Exception e){
        System.out.println("Problem in AppUserDao--getAllMerchants: " + e.toString());
        return null;
    }
}

I get this error:

org.springframework.orm.hibernate3.HibernateQueryException: appuser is not mapped [ from appuser as au where au.securityLevel!=?]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: appuser is not mapped [ from appuser as au where au.securityLevel!=?]

My entity seems to have the necessary annotations. Since it works for the first function, I don’t understand why it doesn’t work for the second.

@Entity
@Table(name="appuser")
public class AppUser {
    private int id;
    private String username;
    private String password;
    private String firstName;
    private String secondName;
    private int state;
    private int securityLevel;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator= "idSeq")
    @SequenceGenerator(name="idSeq",sequenceName="app_user_seq_id")
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }

    @Column(name="password_2")
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getSecondName() {
        return secondName;
    }
    public void setSecondName(String secondName) {
        this.secondName = secondName;
    }
    public int getState() {
        return state;
    }
    public void setState(int state) {
        this.state = state;
    }
    public int getSecurityLevel() {
        return securityLevel;
    }
    public void setSecurityLevel(int securityLevel) {
        this.securityLevel = securityLevel;
    }

}
  • 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-19T14:42:06+00:00Added an answer on May 19, 2026 at 2:42 pm

    Looks like you have a typo in your code.
    In the first function you use “from AppUser ” in the second “from appuser”.
    Try to change the second query to “from AppUser”.

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

Sidebar

Related Questions

hey there i am having problem i have List<List<memoryCard>> that i want to show
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working
I'm having problem with datagrid view. I have attached an image with the code
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
im having problem whith a POST request. I have to receive an XML message
m having problem in passing parameter to controller action, i have done the following
I'm having problem with my class. I'm going to make comparision operators of my
I am having problem in django. I have created a form in my app
I am having problem filtering the mousePressEvent with installEventFilter MyTestxEdit is a widget that

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.