native query « Fetch « JPA Q&A





1. Can I retrieve column names in a JPA native sql query?    stackoverflow.com

Given a simple table (example_table) with the following columns: id, first_name, last_name is it possible, by executing a JPA native sql query em.createNativeQuery("select * from example_table") retrieve the column names as ...

2. How to eager fetch join table collection in Hibernate Native SQL Query?    stackoverflow.com

I have following three database tables

  1. Customer
  2. Product
  3. CustomerProductRelation
Corresponding to these tables, I have two Hibernate POJO's
  1. Product
  2. Customer
One of the member variable is a joinTable:
@JoinTable(name = "CustomerProductRelation", joinColumns = { @JoinColumn(name = "CUSTOMER_ID") ...

3. how to prevent n + 1 fetch in native query?    forum.hibernate.org

5. Help! Native SQL query to retrieve derived object    forum.hibernate.org

Using Hibernate 3.1 I have a case where I have a mapping file for a particular table, and a pojo to represent that table. The mapping file defines two subclasses that are represented by pojos and other respective tables in the DB. I want to execute a native SQL query directly in code (not a named SQL query) to get me ...