简体   繁体   中英

JPA - map entity to sql query?

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 :-/

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!

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM