Announcement Announcement Module
Collapse
No announcement yet.
Hibernate Template question (default collection) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate Template question (default collection)

    Hey,

    I am using a hibernate template to get at a collection of entities persisted in the database. I also create a custom collection class that i use to add additional behavior when objects are being added to the collection within hibernate. The findByNamedQuery method is returning an ArrayList. Is there anyway I can tell spring/hibernate to use my custom collection when building the collection.

    Some code to clarify

    Code:
    CorporateActionList entityList;
    		if(paramValues == null || paramValues.length == 0){
    			entityList = (CorporateActionList) hibernateTemplate.findByNamedQuery(namedQuery); //always returns arraylist
    What facility is available to inform spring/hibernate that I would like a collection of type CorporateActionList to be returned?

    Thanks.

    Roy

  • #2
    This isn't a Spring thing, this method will simply delegate to Query.list(). I'm not sure you'd be able to do what you want, but couldn't you put the results into your list after Hibernate has retrieved them?
    Last edited by karldmoore; Aug 27th, 2007, 04:51 PM.

    Comment


    • #3
      I could but I want to add my own custom behavior to the add and remove method of list interface. I have to do something different to each entity that hibernate retrieves. It's going to be a pretty big list, and I don't want to have to loop thru it more than once.

      Comment


      • #4
        Originally posted by roykachouh View Post
        I could but I want to add my own custom behavior to the add and remove method of list interface. I have to do something different to each entity that hibernate retrieves. It's going to be a pretty big list, and I don't want to have to loop thru it more than once.
        Well I think you'll need to delve into the Hibernate source code. Hibernate has it's own Collection implementations so it can do clever things like lazy loading, I'm not sure what you can do about this.
        Last edited by karldmoore; Aug 27th, 2007, 04:51 PM.

        Comment

        Working...
        X