openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <da...@6degrees.com>
Subject Virtual Entity
Date Thu, 24 Jun 2010 12:07:22 GMT
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:daryl.stultz@opentempo.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message