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

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


Back to the top