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

Could you include your mappings and the SQL that is generated.

Are you using the HistoryPolicy?  Does it work without the HistroyPolicy?

The history table must not use an IDENTITY column, as the id of the source
object will be inserted.

For the date-time issue, what database are you using, and to what level of
precision does it store the date-time?  Are you inserting the same object
and then updating it in another transaction in the same millisecond?



Joe(Zhou Xiangtao) wrote:
> 
> 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.
> 
>  
> 
> 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
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/history-table-cannot-use-automatic-increment-column-as-primary-tp30053636p30067328.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top