質問

I have the Results JPA class containing the folowing anotation.

@JoinColumn (name = "cod_id", insertable = false, updatable = false, referencedColumnName = "cod")
@ManyToOne(optional = true, fetch=FetchType.EAGER)
private TableView dep;

The TableView is an entity which origin is from a view from an another database. So, as far as I can see, I cant access the table directly.

Ok. After this introduction, here it is:

The Problem: When I fetch Results, TopLink JPA queries for each dep one by one. It gets all the resultSet from Results and, then, gets each dep one by one.

The Question: Is there a way to avoid this behavior? In a way that minimize the database server effort?

役に立ちましたか?

解決

You can use a join fetch in your query, or use @JoinFetch in the mapping, or use a batch fetch.

See, http://java-persistence-performance.blogspot.com/2010/08/batch-fetching-optimizing-object-graph.html

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top