Skip to main content

Manfred Riem

I love working with a broad range of technologies. At work it is mostly JavaEE and JavaSE technologies, as a hobby I do some Java on devices.


mriem's blog

JPA Tip #1 - Native Queries

Posted by mriem on August 22, 2007 at 11:30 AM PDT

OK, native queries in JPA. Not really well documented. Of course I understand that we really should not be doing that, but hey there are times where it is just plain easier.

The following code snippet goes after an Oracle sequence and gets the value.

EntityManager em = this.getEntityManager();
Query query = em.createNativeQuery("SELECT BLOG_ITEM_SEQ.nextval FROM DUAL");