I\'m using Hibernate EntityManager, and am experiencing a weird slowdown in my Hibernate queries. Take a look at this code:
public void testQuerySpeed() {
Your executing a native query which is not saying anything about what it will be touching and thus Hibernate will have to (for consistency sake) flush() against all data from all tables it knows about (and your single find() might have fetched more than just one object so it might not be a trivial operation).
To optimize this make sure that you use the SQLQuery.add* methods to define what the query is actually doing. In this case query.addSynchronizedQuerySpace("bogustablename") should do the trick about telling Hibernate that this query is just scalar data from no specific table.