• Post Reply Bookmark Topic Watch Topic
  • New Topic

resultset to multimap, avoding special datatype  RSS feed

 
antonio espinosa
Ranch Hand
Posts: 30
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello code ranchers !

i'm working with jtables and resultsets. I find difficulties working with rowsets in my application, so i want to use collections but i don't want to create a special datatype due to code complextivity
like the following architecture would do.

my goal is to make it the simplest code, after that reuse the code for new queries

this is the closest approach to what i'm thinking





something like this would be a charm

so how i can achieve this? to store data in a collection without a special data type?, to a later time get the values form the rows in the collection
is this possible thank you very much.





 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
antonio espinosa wrote:i'm working with jtables and resultsets. I find difficulties working with rowsets in my application, so i want to use collections but i don't want to create a special datatype due to code complextivity


You have it backward. By NOT defining a class corresponding to the table or rowset you're dealing with, you're making your code MORE complex.

And note that "more code and more typing" isn't the same as "more complex." Usually the opposite is true.

you should define a class for each table or projection or whatever that you're dealing with. If it's too onerous to do it by hand, there are tools that can generate the Java code for you. Once you've got those classes, if you're finding it too tedious to type the code to call all the getters and setters, you can use reflection to do a lot of that for you, or some higher level tool that itself uses reflection. Note, however, that using reflection makes your code much more complex, and it can be error prone and difficult to get right. The benefit is, once you do get it right, you can add more tables without adding more code to deal with them (other than defining the DTO classes).
 
antonio espinosa
Ranch Hand
Posts: 30
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i understand your point, i'll try these higer level tools but would you mind pointing me to those tools and what is the deal with reflection - can a java starter like me try just rigth now reflection ?

thank you very much for all the advices, i apreciate your experience.




what do you think of this.can i use this for later insertions to a database ? , can i get the data manualy inserted to a table model ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!