Note: I had posted this question on eclipse forums but did not receive a reply though I thought my description of the problem was sufficiently clear.
I am posting it here. It will be great if someone can help.
I have a JPA entity class that does not have a table backing it in the database. We simply created it because we had to run a query that needed to perform a join over many tables. So instead of creating a named query, we went the native query way to improve speed. That is we have a JPA Entity like:
@Entity
@SqlResultSetMapping(name = "userMapping", entities=@EntityResult(entityClass =
User.class))
@NamednativeQuery(name = "User.query", query = "-- native query here --",
resultSetMapping = "userMapping")
public class User {
}
Now this runs fine with an entityManager object like: em.createNamedQuery("User.query").setParameter("userParam", param).getResultList();
But while testing this with Testng inside an entitymanager container environment (Created with the EntityManagerFactory), an 0RA-942 table or view does not exist error is thrown. We tried enabling use_native_sql = true in the persistence.properties and in the SessionCustomizer.
We use eclipselink JPA.
can someone help with some feedback on this ?
Thanks