Announcement Announcement Module
No announcement yet.
Need Help - Question regarding PetClinic Example Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Does the question belong to this category??

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

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource"><ref local="dataSource"/></property>
    		<property name="mappingResources">
    		<property name="hibernateProperties">
    				<prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
    				<prop key="hibernate.query.substitutions">true 1, false 0</prop>


    • #3
      Re: Need Help - Question regarding PetClinic Example

      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.




      • #4
        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, 12:32 PM.


        • #5
          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
            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 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?



            • #7
              There is a thread on the dev list discussing this.