I'd like to make use of SequenceGenerator and get the next value from the sequence generator. I want to avoid making a trip to the DB and rely on the sequencegenerator to give me a unique value. Also I am using the value to display the unique id in a display field without persisting the object.
It works in Oracle:
Query q = em.createNativeQuery("SELECT nombreSecuencia.NEXTVAL FROM DUAL");
return (java.math.BigDecimal)q.getSingleResult();