Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Support for Postgresql "ON UPDATE CASCADE"
PostPosted: Mon May 21, 2012 12:25 pm 
Newbie

Joined: Fri Jan 30, 2009 12:03 pm
Posts: 6
Postgresql has a nifty feature "ON UPDATE CASCADE", which allows me to update the value for a Primary Key in the Parent table, and the Child tables will automatically be updated. Is this supported in any way in Hibernate?

For example, in Postgresql:

create table tParent (pKey varchar(16) primary key, f1 int, f2 int);
create table tChild (f1 int, f2 int, fKey varchar (16) references tParent ON UPDATE CASCADE);
insert into tParent values ('OldPkeyValue', 1, 1);
insert into tChild values (2, 2, 'OldPkeyValue');
update tParent set pKey = 'NewPkeyValue' where pKey = 'OldPkeyValue';

This automatically updates tChild to reflect the new value.
I have the need to do the same thing in my Application. I have a primary key (userId) which generally will contain a User's email address. If their address changes, I need to update it. Does anyone know how to do this effectively with Hibernate?
Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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.