-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Getting next value from sequence
PostPosted: Thu Jul 12, 2012 5:08 pm 
Newbie

Joined: Wed Mar 29, 2006 7:16 pm
Posts: 4
I have created a dummy entity like the one below.

@Entity
@GenericGenerator(name = "CA_SEQUENCE_GENERATOR",strategy = "com.mycompany.MySequenceGenerator", parameters = {@Parameter(name = "sequence_name", value = "CA_SEQ"),
@Parameter(name = "increment_size", value = "50")
}
)
public class DummyEntity {

private BigDecimal id;

/** default constructor */
public DummyEntity() {
}

// Property accessors
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="CA_SEQUENCE_GENERATOR")
public BigDecimal getId() {
return this.id;
}

public void setId(BigDecimal Id) {
this.id = Id;
}
}

Here, the whole purpose is that I need to get hold of the Id generated by Hibernate. I dont want to make a call to the DB to get the next sequence value.

public BigDecimal getIdentity(MyObject instance){

entityManager.persist(instance);
entityManager.flush();
return instance.getId();


}

This throws an exception java.sql.BatchUpdateException: ORA-00942: table or view does not exist


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.