Results 1 to 7 of 7

Thread: Need Help - Question regarding PetClinic Example

Hybrid View

  1. #1
    Join Date
    Nov 2004
    Posts
    159

    Default Need Help - Question regarding PetClinic Example

    I just created my first spring app (it's NOT web based application). I'm using JBoss/Hibernate/Spring/Eclipse combination.

    I wrote some POJOs and generated mapping files using XDoclet successfully. Then i created a business interface and spring enabled it. I also created the applicationcontext.xml file.

    So far, i was following the PetClinic example. This example has only one .hbm.xml file petclinic.hbm.xml file. In my application, i've generated one .hbm.xml file per POJO. My question is, how will i list all the .hbm.xml files under the property 'mappingResources' in the 'sessionFactoryBean'?

    Do i need to use 'list' and list all the .hbm.xml files?

    I'm sorry if i had asked some trivial question but i just started working on Spring 2 days ago and new to hibernate too.

    Thanks for your help in advance.

  2. #2

    Default Does the question belong to this category??

    Anyway this is how you'd typically do it, use a 'list'

    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource"><ref local="dataSource"/></property>
    		<property name="mappingResources">
    			<list>
    				<value>/bw/ebs/application/library/system/domain/Copy.hbm.xml</value>
    				<value>/bw/ebs/application/library/system/domain/Fine.hbm.xml</value>
    				<value>/bw/ebs/application/library/system/domain/Book.hbm.xml</value>
    				<value>/bw/ebs/application/library/system/domain/Patron.hbm.xml</value>
    				<value>/bw/ebs/application/library/system/domain/Reservation.hbm.xml</value>
    				<value>/bw/ebs/application/library/system/domain/Section.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
    				<prop key="hibernate.query.substitutions">true 1, false 0</prop>
    			</props>
    		</property>
    	</bean>
    [/code]

  3. #3
    Join Date
    Aug 2004
    Location
    Toulouse, France
    Posts
    148

    Default Re: Need Help - Question regarding PetClinic Example

    Quote Originally Posted by spring04
    Do i need to use 'list' and list all the .hbm.xml files?.
    That's it. The property actually expect a String[]. When you pass a single value it creates a 1 item array, but when using a list, it will create a multi item array and the session factory bean will load them all.

    HTH

    Olivier

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Actually, if you use XDoclet to create the hibernate.cfg.xml file, you can just reference it as shown here.
    Last edited by robyn; May 14th, 2006 at 12:32 PM.

  5. #5
    Join Date
    Nov 2004
    Posts
    159

    Default

    Thanks Everyone.

    It's really great that i can just refer the config location and point to the xdoclet generated .hbm.xml.

    Let me try it out!

  6. #6
    Join Date
    Nov 2004
    Posts
    159

    Default Need Help - Question regarding PetClinic Example

    Using Xdoclet, i'm creating *.hbm.xml files for each POJOs and we don't create .hbm.cfg.xml. We use hibernate.properties as we only need to configure dialect using this. Our environment is JBoss/Spring/Hibernate. In this case, i think i need to use just list to list all the *.hbm.xml files in the applicationcontext.xml file. My concern is that i had to hardcode the path for each and every file. Is there a way i can give the directory information in one place and just use the file names of .hbm.xml file?

    Thanks!

  7. #7
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    There is a thread on the dev list discussing this.

Similar Threads

  1. Replies: 1
    Last Post: Sep 19th, 2005, 09:15 AM
  2. Replies: 4
    Last Post: Jun 15th, 2005, 04:47 PM
  3. Question regarding petclinic build.xml file
    By spring04 in forum Architecture
    Replies: 1
    Last Post: Nov 18th, 2004, 12:59 PM
  4. Replies: 1
    Last Post: Oct 1st, 2004, 10:04 AM
  5. Petclinic question
    By Patrick Vanhuyse in forum Swing
    Replies: 1
    Last Post: Sep 9th, 2004, 08:13 AM

Posting Permissions

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