Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One table Sequeunce key mapping into another table

 
Mohanraj kathiravan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new to this Hibernate World. I hope every body doing well. I am doing an enhancement in existing hibernate application. In this enhancement, DBA team introduced new column in existing table (Transaction table) which will have primary key value of another table (Customer table). For example if any transaction happens in the application, I am inserting details into these tables. Code is given below

try {
s = HibernateUtil.currentSession("EFO");
t = s.beginTransaction();
// save or update the record...
s.saveOrUpdate(customer);
s.saveOrUpdate(transaction);
// commit the updates...
t.commit();
} catch (Exception e) {
if (t != null)
t.rollback();
_log.error("Unable To Save Record [" + transaction + "]", e);
throw new CustomerServiceUnavailableException(
"Unable To Save Record [" + transaction + "]", e);
}

Now I have to add that new column into Transaction table mappings. The value of this column must be sequence key value of the customer table. Both columns are inserted into one by one and when Inserting Transaction, I need to get Customer table inserted sequence value for Transaction.

How to do mapping for this? Or any other suggestions welcome

Thanks In advance
Mohan
 
Mohanraj kathiravan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan wrote:Hi, I am new to this Hibernate World. I hope every body doing well. I am doing an enhancement in existing hibernate application. In this enhancement, DBA team introduced new column in existing table (Transaction table) which will have primary key value of another table (Customer table). For example if any transaction happens in the application, I am inserting details into these tables. Code is given below

try {
s = HibernateUtil.currentSession("EFO");
t = s.beginTransaction();
// save or update the record...
s.saveOrUpdate(customer);
s.saveOrUpdate(transaction);
// commit the updates...
t.commit();
} catch (Exception e) {
if (t != null)
t.rollback();
_log.error("Unable To Save Record [" + transaction + "]", e);
throw new CustomerServiceUnavailableException(
"Unable To Save Record [" + transaction + "]", e);
}

Now I have to add that new column into Transaction table mappings. The value of this column must be sequence key value of the customer table. Both columns are inserted into one by one and when Inserting Transaction, I need to get Customer table inserted sequence value for Transaction.

How to do mapping for this? Or any other suggestions welcome

Thanks In advance
Mohan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic