Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [SELECT u FROM User as u WHERE u.name = :name]
  2.  
  3. @Entity
  4. @Table(name = "PL1_USER")
  5. public class User implements Serializable {
  6. ...
  7.  
  8. @Stateless
  9. public class UserService {
  10.  
  11. @PersistenceContext(unitName = "my-unit")
  12. private EntityManager entityManager;
  13.  
  14. public User getUser(String username) {
  15. TypedQuery<User> query = entityManager.createQuery("SELECT u FROM User as u WHERE u.name = :name", User.class);
  16. query.setParameter("name", username);
  17. return query.getSingleResult();
  18. }
  19. }
  20.  
  21. <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22. xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
  23.  
  24. <persistence-unit name="my-unit" transaction-type="JTA">
  25. <provider>org.hibernate.ejb.HibernatePersistence</provider>
  26. <jta-data-source>java:jboss/datasource/MY-DS</jta-data-source>
  27.  
  28. <jar-file>Entity.jar</jar-file>
  29.  
  30. <properties>
  31. <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
  32. <property name="hibernate.archive.autodetection" value="class, hbm" />
  33. <property name="hibernate.show_sql" value="false" />
  34. <property name="hibernate.format_sql" value="true" />
  35. <property name="hibernate.use_sql_comments" value="false" />
  36. <property name="hibernate.jdbc.batch_size" value="30" />
  37. <property name="hibernate.jdbc.fetch_size" value="100" />
  38. <property name="hibernate.max_fetch_depth" value="0" />
  39. <property name="hibernate.order_updates" value="true" />
  40. <property name="hibernate.use_identifier_rollback" value="true" />
  41.  
  42. <!-- JDBC Driver returns row count for batch statements -->
  43. <property name="hibernate.jdbc.batch_versioned_data" value="true" />
  44.  
  45. <property name="hibernate.dialect" value="org.hibernate.dialect.DB2400Dialect" />
  46.  
  47. </properties>
  48. </persistence-unit>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement