[jboss-user] [JBoss Seam] - Newbie GenericGenerator from stored procedureProblem
slavosk
do-not-reply at jboss.com
Sun Mar 4 17:30:34 EST 2007
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";
| }
| }
|
|
Thank you!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024944#4024944
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024944
More information about the jboss-user
mailing list