• 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

Collections

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a PO class contains a collection of PO detail records, how would you use Spring to instantiate the detail objects to add to the collection? You would not know how many detail objects there were beforehand.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suppose you're looking for this?
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
I suppose you're looking for this?



Lasse am not too clear about this. PO Detail records are determined at runtime for a PO. Do you think we can configure something like that in a config file? I mean specifying static dependencies in a config file makes sense to me. Am i missing something here?
 
author
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karthik,

Can you explain a little bit more what you are looking for. Are you talking about retrieving a PO from the database?
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ryan Breidenbach:
Karthik,

Can you explain a little bit more what you are looking for. Are you talking about retrieving a PO from the database?



Ryan

Referring to Bill's originial post about retrieving PO details for a PO, the link to Spring docs shows how to initialize a list when the values are known up front. If the PO Lines are to be retreived from the database for a given PO, how would the declaration for classes PO, PoDetail look like in the Spring config file.
class PO{
List podetails;
}

I dont know but am just speculating, i hope bill wanted to know the same.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah. I missed the part about the contents of the list being dynamic... Sorry for the confusion.

I actually don't know any other way than to inject your bean with a DAO from which the object can ask for the list contents. I'd obviously be interested to hear about other ways of doing something like this...
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I am understanding the original question correctly...

A PO and it's items are data objects. They describe some piece of business data (not logic). While I suppose that you could wire up a PO and its items in a Spring container, it doesn't make much sense. These items belong in the database.

The types of objects you wire up in Spring are service objects. This includes any service layer objects, DAOs, utility objects, etc. These object do something.

So, to answer your question, you wouldn't likely wire up a PO and its related line items in Spring. Those would be kept in a database and retrieve using JDBC or some ORM solution (like Hibernate).

If (let's say) you decide to use Hibernate. In that case you would wire up (in Spring) a Hibernate session factory and any DAO and service layer objects you need to retrieve the PO and its line items from the database. But the PO and its line items aren't wired...they're in the database.

Does that make sense?
 
Bill Fly
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, pohdr and podtl are database tables. If I create a DAO class to retrieve them from the db tables and load them into a PO bean. The PO bean contains an ArrayList of PODtl objects; one for each row in the podtl table that has the same PO number as the PO header. Spring would instantiate the PO object before entering the DAO class, but how should entries in the ArrayList be created dynamically as rows are returned from the podtl table resultset?
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't have Spring create the PO header and detail beans. The DAO instead should be responsible for creating and saving PO records. Spring would create and wire up the DAO but not the data beans.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would suggest using Hibernate for that.
reply
    Bookmark Topic Watch Topic
  • New Topic