Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] history table cannot use automatic increment column as primary

Hi José,

 

I do use, I think you mean the merge operation.

 

Here is the completely code:  you can find out it may be a bug in eclipse link.

                                Consignee c=new Consignee();

                                c.setAddress1("ssss");

                                em.persist(c);

                                em.flush();

                                System.out.println("!!"+c.getId()); // here the output is 1

                                c.setAddress2("s2");

                                c=em.merge(c);

                                em.flush();

                                System.out.println("!!"+c.getId()); // here the output is 2

 

Regards,

Joe

 

-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of José Arcángel Salazar Delgado
Sent: Tuesday, October 26, 2010 1:39 PM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] history table cannot use automatic increment column as primary

 

On Lun 25 Oct 2010 21:38:25 Joe(Zhou Xiangtao) escribió:

> Hi everyone,

>

>

>

> The problem is when I use an automatic increment id, the java object

> will get the wrong id, could anyone know how to solve it.

>

>

>

> For example:

>

>                 Consignee consignee= new Consignee();

>

>                 // . add some data

>

>                 entityManager.persist(consignee);

>

>

>

> after persist, the consignee.getId() is not the same as in database,

> you can make a test. It's easy.

>

Are you using the returning object from entityManager?

 

something like:

                Consignee c2 = entityManager.persist(consignee);

       c2.getId();

 

>

>

> Plus, if I use a datetime column as primary column, the above problem

> solved,  but the duplicated key exception keeps popup, if  the insert

> and update at same time.

>

>

>

> Regards,

>

> Joe

_______________________________________________

eclipselink-users mailing list

eclipselink-users@xxxxxxxxxxx

https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top