Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Running JPA entity with native queries from TestNG
Running JPA entity with native queries from TestNG [message #1403754] Fri, 25 July 2014 23:09
supraja jayakumar is currently offline supraja jayakumarFriend
Messages: 1
Registered: July 2014
Junior Member
Hi All

I have an entity that has a native query like follows:

@SqlResultSetMapping(name = "userMapping", entities=@EntityResult(entityClass = User.class))

@NamedNativeQuery(name = "User.query", query = "-- native query here --", resultSetMapping = "userMapping")

public class User {


Note that this entity does not have a table name and so there is no User table in the database. This entity was created simply for joining multiple tables quickly when we knew that the resultSet size will be high and so we decided to use native queries instead.

I am trying to test a method (with TestNG) that invokes this query like:


Of course, for purposes of testing, I create a separate entity manager container using the javax.persistence.EntityManagerFactory

But all named queries execute except this one. I turned on "useNativeSQL" in my I am using eclipselink. But it does not execute and complains of:

ORA-942 Table or view does not exist.

While this is a normal exception considering that the "User" table is not there in the database (and I do not have permissions to create a table in the database!), I'd like to know if there is a workaround to overcome this exception. We definitely want to use only native queries here. But testing this code seems to be a problem.

Kindly help.

Previous Topic:Cache coordination with tomcat 6
Next Topic:JAXB : EclipseLink-3002 while unmarshalling xml even JAXB RI works
Goto Forum:

Current Time: Fri Apr 27 01:11:39 GMT 2018

Powered by FUDForum. Page generated in 0.01371 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software