Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32351

Re: JPA and extra fields

From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: JPA and extra fields
Date 2015-08-18 10:49 +0000
Organization A noiseless patient Spider
Message-ID <mqv2ke$u6r$1@dont-email.me> (permalink)
References <87zj1v3vnq.fsf@Equus.decebal.nl> <55cd52c4$0$298$14726298@news.sunsite.dk> <87r3n2sact.fsf@Equus.decebal.nl> <mqsh70$s82$1@dont-email.me> <mqufi0$605$1@dont-email.me>

Show all headers | View raw


On Tue, 18 Aug 2015 06:25:58 +0100, Eternal Hope wrote:

> On 17/08/2015 12:40, Martin Gregorie wrote:
>> I agree about the value of adding columns to tables that are not used
>> by the application and whose sole purpose is the keep track of when
>> rows get updated and by which program. I've used them in the past and
>> used triggers to maintain them independently from the application: by
>> using triggers defined by the DBA and called below application level, a
>> careless programmer can't forget to update them and their maintenance
>> doesn't impact on application logic.
> 
> <humor>
> Ah yes, of course, the infallable and omnipotent DBA cleverly using
> defensive programming to defend against the lazy and incompetent
> developer. It was ever thus. :-)
> </humor>
>
Not quite so much. In a large system you generally have a mix of online 
(interactive) modules and several processes that are run overnight. In a 
system like this it can be quite hard to determine which of the several 
processes that update the database has the reported bug in it. Adding the 
updating program name and a timestamp to each table is low cost, since 
using it merely adds a couple of column changes to a row that's going to 
be updated anyway. In practise its turns out to be a pretty good 
indication of where to start looking for the bug.

> ... but scatters that logic around the different layers of an
> application making it harder to get an overview and consequently
> impacting on the cost of maintenance.
>
I don't agree. If updating the program name and last update time is done 
by a single trigger that is triggered by 'on update' clauses in the 
schema, it doesn't have any impact on the application logic.

Some DBMS support this: others don't and the system designer may choose 
not to use this technique if this sort of trigger isn't supported. Its 
only real flaw is that it doesn't work for tracking deletions: to do that 
you'd need to maintain some sort of changes log and that probably would 
have an impact on throughput. To solve this I like to build the tracing/
debugging code used during development in the live system, but under 
control of debugging controls. This is really useful: if an interactive 
user reports an anomaly you can ask them to switch tracing on, do it 
again and turn tracing off. Once again, finding the fault is generally 
pretty easy.

> Surely the time and place to set created is when the Thing is created
> also who created it.
>
No argument here. In this case I think the two effects are similar and 
that its more a matter of style whether the create/update/delete stamp is 
maintained by the application logic or, if the DBMS has the appropriate 
hooks, as an addition to the schema.
 
> Either you have a cohesive system of 'Objects' or you don't.
> 
Quite. I first did this when I was using a database where it was really 
easy to add a common piece of code that (a) maintained the progname
+timestamp and (b) could dump every record that was read or written to 
the database. It was a single code module that could be invoked for every 
i/o operation on every record type in the database. Its data tracing 
operation could be interactively switched on or off without restarting 
the DBMS, so using it during development was a no-brainer and so was 
leaving it in the live system for trouble shooting.
  
> Just interested that's all.
>
Interesting discussion.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-13 20:12 +0200
  Re: JPA and extra fields Eternal Hope <laughingspam99@gmail.com> - 2015-08-13 20:29 +0100
    Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-17 07:40 +0200
  Re: JPA and extra fields Arne Vajhøj <arne@vajhoej.dk> - 2015-08-13 22:30 -0400
    Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-17 08:22 +0200
      Re: JPA and extra fields Martin Gregorie <martin@address-in-sig.invalid> - 2015-08-17 11:40 +0000
        Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-17 14:36 +0200
          Re: JPA and extra fields Martin Gregorie <martin@address-in-sig.invalid> - 2015-08-17 18:08 +0000
            Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-17 21:24 +0200
              Re: JPA and extra fields Martin Gregorie <martin@address-in-sig.invalid> - 2015-08-17 22:47 +0000
                Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-19 11:32 +0200
          Re: JPA and extra fields Arne Vajhøj <arne@vajhoej.dk> - 2015-08-17 19:48 -0400
        Re: JPA and extra fields Eternal Hope <laughingspam99@gmail.com> - 2015-08-18 06:25 +0100
          Re: JPA and extra fields Martin Gregorie <martin@address-in-sig.invalid> - 2015-08-18 10:49 +0000
            Re: JPA and extra fields Eternal Hope <laughingspam99@gmail.com> - 2015-08-19 09:00 +0100
              Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-19 11:36 +0200
                Re: JPA and extra fields Martin Gregorie <martin@address-in-sig.invalid> - 2015-08-19 10:48 +0000
      Re: JPA and extra fields Arne Vajhøj <arne@vajhoej.dk> - 2015-08-17 19:46 -0400
        Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-19 11:28 +0200
    Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-19 11:53 +0200
      Re: JPA and extra fields Martin Gregorie <martin@address-in-sig.invalid> - 2015-08-19 10:51 +0000
        Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-19 13:14 +0200
          Re: JPA and extra fields Cecil Westerhof <Cecil@decebal.nl> - 2015-08-19 14:19 +0200
      Re: JPA and extra fields Arne Vajhøj <arne@vajhoej.dk> - 2015-08-19 19:13 -0400
  Re: JPA and extra fields Silvio <silvio@internet.com> - 2015-08-20 03:49 +0200

csiph-web