Hi,

We have different business departments and each of these departments have
their own persistent units. Since departments are dynamic, we have thought
of using application-mangaged entity manager based on the persistent unit
passed for respective business unit.

We are creating map of emf for persistent unit and retrieve em out of it. So
one persistent unit is for SQL Server and other for DB2. So far as entities
are concerned, we dont face any issue.

We also have requireement to execute native query and populate POJO with
values. And while executing this scenario we are facing issue.
BranchVO:

//defined BranchVO in persistent.xml

Code to access BranchVO:
//sql query to get data from two tables
        String njSql = "SELECT b.branch_id, b.branch_cust_id,
ba.branch_address_street1 from branch as b," +
                                "branch_address as ba where b.branch_id = ?";

//retrieving em from emf using application-manged entity manager mechanism
EntityManager em = emf.createEntityManager("unitname");

//common code to get the entity lists
//it's failing here saying BranchVO is not enhanced.
Set<EntityType<?>> em1Entitites = em.getMetamodel().getEntities();

I know because it's not a @Entity @mappedsuperclass or @embeddable. If i
make it @embeddable then it says 
org.apache.openjpa.persistence.InvalidStateException: Cannot instantiate
virtual mapping "com.company.vo.BranchVO".

http://openjpa.208410.n2.nabble.com/file/n6841951/BranchVO.java
BranchVO.java 

Hope this helps to understand business scenario we wanted to achieve.

Thanks
Unmarshall

--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Retrieving-POJO-using-Native-Query-tp6841951p6841951.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to