I have virtual entity that has nothing but getters, if you do it his way you can use JPQL referring to the virtual fields and let OpenJPA do the work for you.
Chris -----Original Message----- From: Daryl Stultz [mailto:[email protected]] Sent: Thursday, 24 June 2010 10:07 PM To: OpenJPA User List Subject: Virtual Entity Hello, I've get a many-to-one relationship between tables A and E. E is a "loose" association of A. There is no foreign key in A pointing to E. The relationship is via tables B, C, and D. In SQL, working out this relationship is pretty easy, just joining in the intermediate tables and selecting the values from A and E. I can't use this approach in JPQL, though, since I can't join or filter as there's no physical relationship. I'd like to create a view and write an entity to model the view instead of a table. The problem is that there's no primary key of this "Virtual Entity" nor any compound key that can be formed. So obviously I can't load in this entity as the Persistence Context and caches would not be happy. I'm wondering if I can pick an arbitrary (non-unique) column and label it the primary key just to get enhancing to work, then reference the entity in queries. Something like this: select o.e from MyVirtualEntity o where o.a = :a Will this work? Thanks. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com http://www.opentempo.com mailto:[email protected]
