Results 1 to 2 of 2

Thread: Prototype object in spring

  1. #1

    Default Prototype object in spring

    I used spring 2.5.
    I create a class "SalesServiceImpl" and i configered in .xml as prototype.

    <bean id="salesService"
    class="com.brainscript.financepoc.sales.service.im pl.SalesServiceImpl" scope="prototype">
    <property name="salesDao" ref="salesDaoTarget"></property>
    <property name="batchService" ref="batchServ"></property>
    </bean>

    Then i print the hashCode value of .salesService, each time i get the same value, that means this object is not a prototype.

    So how can i create a prototype object in spring?

  2. #2
    Join Date
    Dec 2008
    Location
    Hyderabad, India
    Posts
    18

    Default hashCode() implementation?

    Hi Aju,

    Can you provide the hashCode() implementation present in your bean?
    It is possible to have multiple instances of same class to have same hash code.

    For example --->

    public int hashCode() {
    return 10;
    }

    For every instance of this class, hashcode will be 10.

    If you want to check whether a new instance has been created or not by the container, when ever you do getBean() sort of thing, then put a SOP with "this" - it will show the object reference. Make sure that you don't have a toString() implementation in your class.

    Regards,
    Sreeram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •