Native SQL « POJO « JPA Q&A





1. How can mapped result from SQL native query to java POJO class (no entity)    stackoverflow.com

I have simple java pojo and it's no entity.

class MyClass {
    // fields, getter, setter and etc...
}
Also I have DAO with some function for execute native SQL query ...

2. Unmapped POJO used as class type in a native query's result exception    stackoverflow.com

Given a class:

class MyClass {
    private String a;
    private String b;
    private String c;
}
and code like so:
Query q = getEntityManager()
  ...

3. creating POJO every time I have to use native sql ?    forum.hibernate.org

Hi all I wonder if I use with a native sql inside, I have to specify a specific POJO for retrivining all the columns or It's enough getting the list and after that acting as with HQL. I do not want create a POJO every time I have to use native sql inside an hbm mapping file. Exists any alternative? ...

4. How to make a native sql query that return pojos?    forum.hibernate.org

Caused by: org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1596) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153) at be.rmi.shark.hibernate.persistence.PersistenceManager.nativeList(PersistenceManager.java:189) ... 41 more Caused by: java.sql.SQLException: Nom de colonne non valide ...

5. Native SQL: How to annotate POJOs correctly?    forum.hibernate.org

@Entity @Table (name="TESTTABLE") public class Test implements Serializable{ private Integer fooBar; private String barFoo; private String fax; @Id @Column(name="FOOBAR") public Integer getFooBar() { return fooBar; } public void setFooBar(Integer fooBar) { ...