openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim O'Rourke <>
Subject NamedNativeQuery and Eager Fetch
Date Sat, 21 Mar 2009 16:39:32 GMT

Not sure if this is expected behavior, or a mistake on my part, so I thought
I'd ask...

I have an entity with an eager ManyToOne relationship.  Native queries run
as query.getResultList()  are returning NULL for the related entity, while
query.getSingleResult() return a populated related entity.  The only
workaround I've found is to iterate and em.find(entity.class,
entity.getID()), but that's having a dramatic negative impact on my query
time, and these are pretty heavily used queries in my app.

Any help would be appreciated.

I'm using OPenJPA 1.1.0 (bundled with OpenEJB 3.1)

The following properties are defined in persistance.xml:
	<property name="openjpa.jdbc.EagerFetchMode" value="parallel"/>
	<property name="openjpa.jdbc.SubclassFetchMode" value="join"/>

My entity looks something like:

		query="SELECT p.* FROM Price p WHERE p.symbol = ? " +
				" AND p.pricedate <= ? " +
				" ORDER BY p.pricedate DESC LIMIT 1"
public class Price (
	public static final String

	@Id private Integer id;
	@Temporal(DATE) private Date pricedate;
	private Double amount;
	@ManyToOne(optional = false, fetch = EAGER, cascade = { MERGE, REFRESH })
	private Symbol symbol;

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message