Hi,
Have you done any other configuration of the sequence elsewhere? Also,
can you turn SQL and JDBC logging to TRACE and post the logs?
I think I remember a thread about a similar topic in the last couple
of months, btw. I don't remember what, if anything, the resolution
was.
-Patrick
On 9/20/07, ben short <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a simple class as shown below...
>
> Entity
> @SequenceGenerator(name="CategoryIdGen", sequenceName = "CategoryIdSeq")
> public class Category
> {
> @Id
> @Column(name="id")
> @GeneratedValue(strategy= GenerationType.SEQUENCE, generator =
> "CategoryIdGen")
> private Long mId;
> }
>
> Given the following code and assuming that the sequence is equal to 0,
> I would expect that category would get an id of 1 and category2 an id
> of 2. But this is not the case, category gets an id of 1 and category
> gets an id of 51.
>
> EntityManager em = entityManagerFactory.createEntityManager();
>
> em.getTransaction().begin();
>
> Category category = new Category();
> category.setName("Category");
> category.setDescription("Category");
> Category category2 = new Category();
> category2.setName("Category");
> category2.setDescription("Category");
>
> em.persist(category);
>
> em.persist(category2);
>
> em.getTransaction().commit();
>
> It would seem that the db allocates 50 ids at a time, as expected, yet
> openjpa doesn't use them up, it just calls the generator again.
>
> I'm using postgresql and openjpa-1.1.0-SNAPSHOT.
>
> I have search the JIRA but cant see a bug of this description. Is this
> a known issue?
>
> Regards
>
> Ben Short
>
--
Patrick Linskey
202 669 5907