Hibernate version:3.2.2.ga and JBoss 4.1 - NetBeans 5.5 - MySql 5
stack trace of any exception that occurs:
Code:
11:36:14,666DEBUG SecurityAssociation:143 - Using ThreadLocal: false
11:36:14,715DEBUG Client:514 - invoke called, but our invoker is disconnected, discarding and fetching another fresh invoker for: InvokerLocator [socket://127.0.0.2:3873/]
11:36:14,715DEBUG SocketClientInvoker:275 - connect called for: org.jboss.remoting.transport.socket.SocketClientInvoker@15d56d5
javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: USR is not mapped [SELECT DISTINCT OBJECT(k) FROM USR k WHERE k.username = ?1]
...
Caused by: org.hibernate.hql.ast.QuerySyntaxException: USR is not mapped [SELECT DISTINCT OBJECT(k) FROM USR k WHERE k.username = ?1]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
My EJB3 methodCode:
public Usr getUsrByUsername(String _username) throws UsernameException {
if(_username==null) throw new UsernameException("The username value cannot be null.");
Usr user = (Usr)em.createQuery("SELECT DISTINCT OBJECT(k) " +
"FROM USR k WHERE k.username = ?1").getSingleResult();
return user;
}
Persistence.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="Users-EJBModulePU" transaction-type="RESOURCE_LOCAL">
<!-- Jboss uses hibernate as default persistence engine
<provider>org.hibernate.ejb.HibernatePersistence</provider> -->
<jta-data-source>java:/MySqlDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<!-- Show and print nice SQL on stdout -->
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<!-- Drop and create a new DB each time - Use only on development-->
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
I'm using annotationsCode:
@Entity
@Table(name="USR")
public class Usr implements java.io.Serializable {
Anyone can tell me where I'm making the mistake?
Thanks in advance