Hi,
i have problems to get id from a stored procedure. I'm getting allways the "NOK" value from my Generator. (Problem with persistence context ?)
Is it possible, or what am I doing wrong?
@GenericGenerator(name="next_id", strategy="com.myapp.DBSequenceGenerator") @Id @GeneratedValue(generator="next_id") @Column(name = "product_id", unique = true, nullable = false, length = 20) @NotNull @Length(max = 20) public String getProductId() { return this.productId; }
@Stateless public class DBSequenceGenerator implements IdentifierGenerator { @PersistenceContext EntityManager em; public DBSequenceGenerator() { // empty constructor } public Serializable generate(SessionImplementor arg0, Object arg1) throws HibernateException { try { Query q = em.createNativeQuery("select get_next_id from get_next_id('nativequery')"); //........ } catch (Exception e) { return "NOK"; } return "OK"; } }