I'm using SqlResultSetMapping
and the Entity
annotations (SqlResultSetMapping requires an Entity with an Id) to tell Hibernate how to populate instances of Foo
with native query results data.
Non-persisted entity:
@SqlResultSetMapping(name = "fooMapping", entities = @EntityResult(entityClass = Foo.class))
@Entity
public class Foo {
@Id
public Long row_id;
public String name;
}
Native query:
String sql = "SELECT id AS row_id, friendlyName AS name FROM SomeTable";
Query q = JPA.em().createNativeQuery(sql, "fooMapping");
List<Foo> fooList = q.getResultList();
The problem is, a table called "Foo" gets created automatically for me (using Play! Framework in dev mode), but Foo is not a model and should not be persisted.
How do I instruct hibernate not to create this table?