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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:49:31+00:00 2026-05-16T08:49:31+00:00

I am having a problem with Hibernate seeing my domain objects doing a purely

  • 0

I am having a problem with Hibernate seeing my domain objects doing a purely annotation configuration for Hibernate.

I’m getting

org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User u where u.userName=:userName]

I thought all that had to be done was add the packagesToScan property for the sessionFactory and add @Entity to the domain object. What else am I missing?

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="com.trx.sample.domain" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
        </props>
    </property>
    <property name="eventListeners">
        <map>
            <entry key="merge">
                <bean
                    class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
            </entry>
        </map>
    </property>
</bean>

<context:annotation-config />
<tx:annotation-driven />

–

package com.trx.sample.domain;

@Entity
@Table(name = "user")
public class User extends BaseEntity implements UserDetails {

  private static final long serialVersionUID = 1L;

  @Column(name = "user_name")
  private String userName;
  private String password;
  private boolean enabled;
  private String roles;

  ...
}

–

@MappedSuperclass
public class BaseEntity implements Serializable {
  private static final long serialVersionUID = 1L;

  @Id
  @GeneratedValue
  private Long id;

  public void setId(Long id) {
    this.id = id;
  }

  public Long getId() {
    return id;
  }

  public boolean isNew() {
    return (this.id == null);
  }
}

–

[INFO] building session factory
[DEBUG] Session factory constructed with filter configurations : {}
[DEBUG] instantiating session factory with properties: {...}
[DEBUG] initializing class SessionFactoryObjectFactory
[DEBUG] registered: 402881e52a6b3159012a6b3163e40000 (unnamed)
[INFO] Not binding factory to JNDI, no JNDI name configured
[DEBUG] instantiated session factory
[DEBUG] Checking 0 named HQL queries
[DEBUG] Checking 0 named SQL queries

Edit:

Don’t know if it makes a difference or not but I’m running it through eclipse on a tomcat instance.

  • 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-16T08:49:32+00:00Added an answer on May 16, 2026 at 8:49 am

    Hanging my head in shame as I answer this. The @Entity import was incorrect.

    This particular domain object used

    import org.hibernate.annotations.Entity;
    

    when it should have been using

    import javax.persistence.Entity;
    

    gah!

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

Sidebar

Related Questions

Ok so I'm having bit of a problem with my Hibernate mappings and getting
Having a frustrating problem with Hibernate 3.6.9. MS SQL Server 2008. Note the exception
I'm having a problem implementing a bi-directional parent/child relationship using hibernate 3. The parent,
I'm having a problem with Eclipse and the content assistant regarding Hibernate. As far
I'm having a problem with an HQL query Three classes ClassOne is my BusinessObject
I'm having a weird problem using Spring and Hibernate. I started using Hibernate using
i'm having a light problem with liquibase and hibernate.I expect hibernate to create the
I'm having a major problem getting a parent/child relationship working for a hierarchy of
I´m having a problem with nativeid and i don´t know if i am doing
I'm having some trouble getting the hang of HQL. I have an application where

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.