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 18:07:51 GMT
Not sure about OpenJPA 2.0 but on 1.2.2 views on MySQL was totally broken.

-----Original Message-----
From: Matthew Adams [] 
Sent: Friday, 25 June 2010 3:46 AM
Subject: Re: Virtual Entity

Instead of a virtual entity, you could create the view and tell
OpenJPA about the view via @JoinTable annotations...

On Thu, Jun 24, 2010 at 5:07 AM, Daryl Stultz <> wrote:
> 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
> 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.


View raw message