• 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

read method (UB)

 
Greenhorn
Posts: 16
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy,
I'll start with an explanation and end with the question
Currently in my read method I seek a record and read the entire thing so that only a small bit of code has to be synchronized. Then I take that byte array and go through it in a for loop (with a few nested for loops ). Should I go this route or to cut down on nested blocks should I read stuff out one field at a time (more code in synchronized block). Stupid question I know but I am just really paranoid about code complexity (nested loops seem to be a no no even though they aren't that confusing). The other question I had was concerning a VacantRoom or Record DTO, I imagine anyone who used it didn't change the sun/oracle provided Interface so that the read method returned a DTO so how were you able to use it? It would probably be nice for front end validation but I was wondering if there was a way to get around the DB interface's read method (call it with another method that changes a String[] into DTO but then I wouldn't want read to be public or maybe it wouldn't matter blablabla).
Thanks Partners,
Andy
 
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 Andy,

Welcome to the JavaRanch!

1/ I synchronized the complete methods of the Data class (a simple approach but less performant). Just like you I read the complete record and then I convert the bytes to a String[]. To convert the bytes into the String[] I just need 1 for loop. Maybe I also have to mention that I don't use a static database schema but I also read it from the database file.

2/ If you do not want to fail automatically, do NOT change the interface you got. I created an own interface which extends the given interface and added a few extra methods. None of these extra methods used a transfer object. I opted for a thin client approach and that's where the transfer objects come into play I created a business service with a few methods and these methods use transfer objects, so it's the business service which converts from String[] to transfer object (and vice versa). In the Data class itself I work with String[] (which makes my Data class also usable for a database file with customers or hotels)

Hope it helps!
Kind regards,
Roel
 
Andy Gertjejansen
Greenhorn
Posts: 16
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea I just thought about it a little harder and realized that I can do it with one for loop as well. DTO in the business layer, I could see how that would be nice. Thank you sir, I really appreciate the help.
Thanks Partner,
Andy
 
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
Your last name sounds very Dutch, so are you from the Netherlands?
 
Andy Gertjejansen
Greenhorn
Posts: 16
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am nearly a full blooded German with a Norwegian name that lives in Minnesota, USA . For some reason your name struck me as Spanish or maybe Italian, but your from Belgium right? That is why I love this site, it seems to bring the world a little closer heh, no it's just really cool to see the diverse selection of people that can get together and help each other with their common propensity...Software developing
Thanks,
Andy
 
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

Andy Gertjejansen wrote:your from Belgium right?


 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic