Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32336
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JPA and extra fields |
| Date | Mon, 17 Aug 2015 14:36:30 +0200 |
| Organization | Decebal Computing |
| Lines | 81 |
| Message-ID | <87io8ert0x.fsf@Equus.decebal.nl> (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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx02.eternal-september.org; posting-host="528adfd6ad074c92fdc6a7f8fb9e23d8"; logging-data="12862"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Cq8nxjzUd3zHR2M51NJCOLnzldbo5Xvs=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Cancel-Lock | sha1:N/srJUKSpoKWTmsLg5iSEF3O8JY= sha1:yJif2qtSLKOI2GSflPy2lReQ9hk= |
| X-Homepage | http://www.decebal.nl/ |
| Xref | csiph.com comp.lang.java.programmer:32336 |
Show key headers only | View raw
On Monday 17 Aug 2015 13:40 CEST, Martin Gregorie wrote: > On Mon, 17 Aug 2015 08:22:10 +0200, Cecil Westerhof wrote: > >> On Friday 14 Aug 2015 04:30 CEST, Arne Vajhøj wrote: >> >>> On 8/13/2015 2:12 PM, Cecil Westerhof wrote: >>>> I am new to JPA. I have to migrate a JDBC application to JPA. For >>>> a certain class there are some extra fields in the table that are >>>> not in the class itself. (For example creation time, modification >>>> time and user that created the entity.) Is it possible to keep >>>> those fields in the table and updated, without putting the values >>>> in the class? >>> >>> I can see different ways of moving forward. >>> >>> 1) >>> >>> Keep those fields out of the class an update them in the database >>> via triggers. >>> >>> Possible create a view without those fields and have the entity >>> map to that instead of the table. >>> >>> 2) >>> >>> Add the fields to the class but do not expose them in its public >>> API. And let them be updated internally. >>> >>> Possible by mapping fields and either no getter/setter or >>> protected. >>> >>> 3) >>> >>> Add the fields to the entity class the normal way but create a new >>> domain class without the fields and convert from entity class to >>> domain class when leaving DAL. >> >> The first option seems the best to me. (But I am not sure it is >> possible with all fields.) Is also depending on the database. The >> application uses a CISC database. I am not sure if these have this >> capability. >> >> But I think I have to use the second possibility. >> > Does the system have an owner who is generally responsible for > change management, agreeing enhancements etc? If so what do they say > about these fields? I wish. :-( I have to find out what the different things mean. At least I managed to get some old documentation that describes the tables. (On the SQL level.) Another part of the problem that there is also Cobol code which maintains another part of the functionalities. So my hands are a bit tied. > 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. I started implementing these values. I hope to get tomorrow some information about if it can be done with triggers. But I am afraid not. For example booleans are done with char of one long. I think I write an annotation for those. But I also have to save the user that created/mutated. For those I can not use triggers I think. So those still have to be implemented. Well, I dive further into the code to understand what it is doing. ;-) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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