-->
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.  [ 2 posts ] 
Author Message
 Post subject: Historical record keeping
PostPosted: Wed Feb 14, 2007 9:25 am 
Newbie

Joined: Mon Feb 05, 2007 11:49 am
Posts: 13
Hello.

I'm writing an EJB 3.0 application that tracks changes made to some fo it's tables. Let's say we have a table PERSON. This table will have 4 columns, PERSON_ID, VERSION, NAME and AGE. The tables primary key will be (PERSON_ID, VERSION).

Question 1: in the composite primary key, the PERSON_ID column should be auto-generated (via oracle sequence, for example), and the VERSION should me maintained by code. How can I implement this behaviour?

Question 2: To keep track of changes, every time I create or modify an object I frist create it's clone in the database. If for example I create the 20 year old Kenny, two records would be added to the database, (1, 0, Kenny, 20) and (1, 1, Kenny, 20). If Kenny was to age one year, the record (1, 1, Kenny, 20) would become (1, 2, Kenny, 21) and the record (1, 1, Kenny, 21) would be added.
I'm trying to do this using Entity Listeners, but I keep getting the following exception:

12:45:18,883 ERROR [STDERR] javax.ejb.EJBException: javax.persistence.Persistenc
eException: org.hibernate.id.IdentifierGenerationException: ids for this class m
ust be manually assigned before calling save(): ejb3tests.Person
...

Can anyone get me some ideas on how to get arround this?

Thanks in advance,

Hugo Oliveira


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 8:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you should be able to find by searching the forums this has been answered many many times.

_________________
Emmanuel


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

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.