<p>I'm writing a JPA connector to a legacy sistem. The problem is, DB design in the system is.. well.. horrible.</p>

<p>I need to implement an entity that maps to three tables. I can do it using named sql queries, but the probem is, I have to use this entity in a OneToMany relation (this entity is on the many side). So how do I tell JPA it needs to use a specific named query with specific parameter?</p>

<p>And a subquestion: does any1 have any good on-line JPA documentation? I can't find anything decent :-/</p>

I haven't actually found a way to do this with JPA. To solve problems like this I ended up using a named query.
As far as documentation, I have been using
TopLink's
and
Hibernate's
.
If you find a better way, please post it here!