• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Arnaud Vandyck
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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: 2
  • Mark post as helpful
  • send pies
  • 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: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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 )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic