• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to get VO object from Spring factory

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have developed simple in that i have show table details in VIEW component

,i have divided this task in 3 components
1) DAO
2)SERVICE
3)VIEW









but i am getting this output i am not table details correctly
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well there are few suggestions that I can make to start your off

1.) Code to interfaces not implementations
2) Use Spring JDBC
3) Take a look at using Springs component scanning and stereo type annotations to make bean configuration much easier.
4) Close your result set and connection or see #2 and let spring handle that for you.
5) As far as naming conventions and package structure you are a little off of the current conventions. This is really a matter of personal choice as well but if you are interested you could have a read of this link (just ignore the web-app directory in your case)
http://gordondickens.com/wordpress/2012/07/03/enterprise-spring-best-practices-part-1-project-config/


But since I did not see any question that you actually asked in your post I am not quite sure what you are looking for from us.

 
raj talatam
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
( HOW to INJECT VO object into DAO lAYER)

i am new to spring, i got a requirement in that i have to get all Department Details(Dept_Name,Dept_Id) from DEPARTMENT table in hr SCHEMA FROM Oracle .
i started coding from DAO Layer,
in that i retrieved Data from DBS, and Stored in ARRAYLiST , by Using VOobject

but in spring we are not creating VOObject directly, i am injecting by using spring config file

BUT i am not able do that, i am getting same 270 record repeatedly,




 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring beans are by default singletons so you do not want these to be Spring beans unless you want the same instance everywhere. So the answer to your question is you would not want to. Also note that when you use the new operator on the DepartmentSearchVO you will not get the spring managed bean but rather new one up. Since you have made this an instance variable this object is the same for each instance of DepartmentSearchDAOImpl (of which there is only one since it is a singleton)

Delete this from DepartmentSearchDAOImpl



I suggest you use typing on your collections, as well as coding to the interface rather than the implementation.

so change it to something more like this



And change this in your main method



to



also I would also suggest not using _ in method names it is unconventional although allowed.

You would then also remove the VO from your bean definition




I hope that helps get you started and answers your question. Good luck.
 
raj talatam
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you Bill Gorder
 
raj talatam
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gorder i got the Answer what i required, thank you for that..

but i got a doubt in that,
According the code which you posted

i am creating object for DepartmentSearchVO by using new operator

but we should not do it in spring, we have to inject dependencies right
i am not sure on this can you explain it , why we are not Injecting VO
object into dAo layer
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well it comes down to what I was talking about earlier. Spring beans are singletons (only one instance). Some sorts of objects don't make sense to be spring managed beans. Value/model objects and Data transfer objects usually fall into this category. These types of objects are typically simple POJO's that just hold the state of the object they represent. They typically don't hold references to services or repositories or things that would be Spring beans.

Now services and repositories and controllers are different these we only need one instance, and they are good candidates to be managed by Spring.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic