openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <daryl.stu...@opentempo.com>
Subject Re: Virtual Entity
Date Mon, 28 Jun 2010 20:10:49 GMT
On Thu, Jun 24, 2010 at 1:45 PM, Matthew Adams <matthew@matthewadams.me>wrote:

> Instead of a virtual entity, you could create the view and tell
> OpenJPA about the view via @JoinTable annotations...
>
> Matthew, I'm wondering if you can give a few more details here. It seems
pretty straightforward, yet OpenJPA is throwing an exception. So A has a
field for E where the relationship is defined by a view. Suppose the view is
named logical.a_e with FK columns a_id, and e_id.

A:E from an ER-perspective is a many-to-one. I'd prefer this to be
unidirectional, though I'd be willing to make it bidirectional.

So I define A.e something like this:

@ManyToOne(fetch = FetchType.LAZY)
@JoinTable(schema = "logical", name = "a_e",
joinColumns = @JoinColumn(name = "a_id"),
inverseJoinColumns = @JoinColumn(name = "e_id")
)
private E e;

I'm not real fluent with @JoinTable. I've tried other variations. It's
throwing something like this:

Caused by: <openjpa-1.2.2-r422266:898935 fatal user error>
org.apache.openjpa.persistence.ArgumentException:
You have supplied columns for "yadda.yadda.A.e <element:class
java.lang.Object>", but this mapping cannot have columns in this context.

I searched on this error and it seems there may be a problem with ManyToOne
and JoinTable. I don't really understand what I found. I tried
SecondaryTable but since A.e is nullable, this doesn't seem to be the right
solution.

I'm using OpenJPA 1.2.1.

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