tags:

views:

1772

answers:

3

Hi,

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

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?

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

+1  A: 

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!

laz
A: 

Could you make a database view and then create an entity that maps onto that view? I don't know if this is possible, just a thought.

Juha Syrjälä
Also (in MS SQL Server at least) you can create an 'INSTEAD OF' trigger on the view to allow JPA to insert to the view and have the correct data go to the 3 tables.
John K
A: 

Take a look at @SecondaryTable(s). There's some examples of this in the Pro EJB 3 Java Peristance API book, page 237.

NA