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: Every Update is save in Table
PostPosted: Mon Feb 04, 2008 3:52 pm 
Newbie

Joined: Thu Jan 17, 2008 1:12 pm
Posts: 8
I am using hibernate with JPA..
In my database the tables have a active indicator column which takes in 0 or 1.

When i update a column on an existing row i should create a new row and
update the active indicator on the existing row to 0 from 1. Which means that i do not update any columns in my tables.I have to create new rows even on updates.

Is there an elegant way in JPA to do this...I am thinking in terms of a common method to all the tables....

any ideas on how to go about this???


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 5:12 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Amar,

There is nothing inherently difficult in what you just said, since you are only using a subset of the Hibernate capabilities (i.e, you will just insert).

You can call your business methods whatever you want (e.g "update") and then let you hibernate DAO do the flagging/insertion).

The only difficulty I foresee, is that your Business side can't use the Hibernate row id at all, since this will change on any new update. You will have to ensure that all your tables using this mechanism have alternative (natural, candidate) keys, meaningful on the business side.

_________________
Gonzalo Díaz


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.