openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <>
Subject RE: Virtual Entity
Date Thu, 24 Jun 2010 12:33:13 GMT
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


-----Original Message-----
From: Daryl Stultz [] 
Sent: Thursday, 24 June 2010 10:07 PM
To: OpenJPA User List
Subject: Virtual Entity


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?


Daryl Stultz
6 Degrees Software and Consulting, Inc.

View raw message