org.hibernate.hql.ast.QuerySyntaxException:用户未映射[来自用户用户]

时间:2014-04-15 14:49:21

标签: java mysql hibernate

有人可以帮助我摆脱这种情况吗?

Users.java

@Entity  
@Table(name="users")  
public class Users {

    @Id
    @Column(name="id") 
    private int id;

    @Column(name="name")
    private String name;

    @Column(name="city")
    private String city;

    @Column(name="salary")
    private Long salary;

    @Column(name="email")
    private String email;

        //getters and setters    
}

的applicationContext.xml

 <bean id="sessionFactory"   
 class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

 <property name="dataSource" ref="dataSource"/> 

// Dont Understand whether internaly its reading the class or not!

 <property  name="packagesToScan" value="com.project.entities"/> 

 <property  name="hibernateProperties"> 
 <props>  
 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>   
 <prop key="hibernate.show_sql">true</prop> </props>
 </property> 

 </bean>

来自持久层的方法

public List<Users> getAllUsers(){

    String queryString = "from Users users";
    List<Users> list =  htemp.find(queryString);
    return list;
}

0 个答案:

没有答案