Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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]
- @Entity
- @Table(name = "PL1_USER")
- public class User implements Serializable {
- ...
- @Stateless
- public class UserService {
- @PersistenceContext(unitName = "my-unit")
- private EntityManager entityManager;
- public User getUser(String username) {
- TypedQuery<User> query = entityManager.createQuery("SELECT u FROM User as u WHERE u.name = :name", User.class);
- query.setParameter("name", username);
- return query.getSingleResult();
- }
- }
- <persistence 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_2_0.xsd" version="2.0">
- <persistence-unit name="my-unit" transaction-type="JTA">
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
- <jta-data-source>java:jboss/datasource/MY-DS</jta-data-source>
- <jar-file>Entity.jar</jar-file>
- <properties>
- <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
- <property name="hibernate.archive.autodetection" value="class, hbm" />
- <property name="hibernate.show_sql" value="false" />
- <property name="hibernate.format_sql" value="true" />
- <property name="hibernate.use_sql_comments" value="false" />
- <property name="hibernate.jdbc.batch_size" value="30" />
- <property name="hibernate.jdbc.fetch_size" value="100" />
- <property name="hibernate.max_fetch_depth" value="0" />
- <property name="hibernate.order_updates" value="true" />
- <property name="hibernate.use_identifier_rollback" value="true" />
- <!-- JDBC Driver returns row count for batch statements -->
- <property name="hibernate.jdbc.batch_versioned_data" value="true" />
- <property name="hibernate.dialect" value="org.hibernate.dialect.DB2400Dialect" />
- </properties>
- </persistence-unit>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement