Ciao a tutti,
mi sto sporcando le mani con EJB3, Annotations e Hibernate.
Il mio problema è per il momento legato ad un errore proveniente da Hibernate:
Hibernate version:3.2.2.ga and JBoss 4.1 - NetBeans 5.5 - MySql 5
stack trace dal client
EJB3 methodcodice: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)
codice: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.xml
codice:<?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/persisten...stence_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"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> </properties> </persistence-unit> </persistence>
annotations - PoJO
Qualche idea sul perchè ho quell'errore?codice:@Entity @Table(name="USR") public class Usr implements java.io.Serializable {
Grazie in anticipo
Ciao

Rispondi quotando