• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[Bodgitt and Scarper] Duplicate key and record number in transfer object

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

In Bodgitt and Scraper DB interface, the methods take and return String[] as parameters. Anyway, I think it's better to create a "Contractor" transfer object that will store the informations in a more OO way ;-)

I got to questions:
  1. Does the record number have to be stored in the bean?
    I'm doing it but I'm not sure.

  2. What is a Duplicate Key?
    I'm using only the name of the contractor and that's the way I'm implementing equals and hashCode.

Am I in a right direction or did I missed something?

Many thanks for your help (I'm sure I'll have some other questions),

Arnaud.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arnaud,

A warm welcome to the JavaRanch!

1/ I stored the record number in my transfer object (only used it in my business layer and client side, in Data class I just used String[] without adding the record number as an element of the array).

2/ I had the URLyBird assignment and no key in that assignment. But I believe in B&S assignment most people implemented duplicate key using the name and the location.

As an important rule: don't forget to document your decisions in choices.txt

Kind regards,
Roel
 
Arnaud Vandyck
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

2/ I had the URLyBird assignment and no key in that assignment. But I believe in B&S assignment most people implemented duplicate key using the name and the location.


That was the first scenario but I changed my mind ;-) I'll use name AND location, thanks.
Does it make sens to have an hashmap with hashcodes of 'name and location' and value would be the record number so it'd be faster to find duplicates?

As an important rule: don't forget to document your decisions in choices.txt


Yep! I already have some open points in that file ;-)

Thanks
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Arnaud Vandyck wrote:Does it make sens to have an hashmap with hashcodes of 'name and location' and value would be the record number so it'd be faster to find duplicates?



It makes sense, but you have to do some more thinking about it (and decision taking): if you allow changes in your update method of name and/or location, you will have to keep this map up-to-date with a removal of old hash code and an insert of the new one. You could disable updating these fields, because they are primary key, but you will have to document that again (one open point less )
reply
    Bookmark Topic Watch Topic
  • New Topic