If the query ends up being vendor-specific then you might actually want to just use the properietary API and save the DB trip.
SessionManager.getSession("mySession").getIdentityMapAccessor().initializeIdentityMap(MyEntity.class);
In JPA 2.0 there will be a standard API to do this.
[Message sent by forum member 'mkeith' (mkeith)]
http://forums.java.net/jive/thread.jspa?messageID=278272