I have mapped my table correctly in the hbm.xml file. In addition, I also included the resource file (User.hbm.xml) in the hibernate config file. My config file is similar to the one below:
hibernate.cfg.xml
Code:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:comp/...</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.jdbc.use_get_generated_keys">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<mapping resource="testSHJ/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
User.hbm.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="testSHJ.User" table="user">
<id name="id" column="id">
<generator class="native"></generator>
</id>
<property name="profile_id" column="profile_id"/>
<property name="realm" column="realm"/>
<property name="username" column="username"/>
<property name="password" column="password"/>
<property name="created" column="created"/>
<property name="modified" column="modified"/>
<property name="lastlog" column="lastlog"/>
<property name="failed" column="failed"/>
</class>
</hibernate-mapping>
I am using the latest version of hibernate and Spring 1.28. However, when I query the class, I get the following error:
Code:
org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: from testSHJ.User u where u.realm = ?; nested exception is org.hibernate.MappingException: Unknown entity: from testSHJ.User u where u.realm = ?
org.hibernate.MappingException: Unknown entity: from testSHJ.User u where u.realm = ?
My query is: getHibernateTemplate().get("from User u where u.realm = ?",realm)