-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How to make use of more than one hbm.xml in application
PostPosted: Mon Mar 13, 2006 9:46 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 3:26 am
Posts: 21
I want to use more than one hbm.xml i.e one hbm per class.

my config file dataAccessContext-local.xml consists of

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>

<property name="mappingResources">
<!--<value>petstore.hbm.xml</value>-->
<list>
<value>Bannerdata.hbm.xml</value>
<value>Account.hbm.xml</value>
</list>
</property>



<property name="hibernateProperties">
<props>

<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="use_outer_join">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>





</props>
</property>
<property name="eventListeners">
<map>
<entry key="merge">
<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
</entry>
</map>
</property>

My Bannerdata.hbm.xml is as follows


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>


<class name="org.springframework.samples.jpetstore.domain.Bannerdata" table="bannerdata" lazy="false">

<id name="favouriteCategoryId" type="string" unsaved-value="null" >
<column name="favcategory" sql-type="varchar(80)" not-null="true"/>
<generator class="assigned" />
</id>
<property name="bannerName" column="bannername"/>
</class>
</hibernate-mapping>



My Account.hbm.xml is as follows


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>


<class name="org.springframework.samples.jpetstore.domain.Account" table = "account" lazy="false">

<id name="username" type="string" unsaved-value="null" >
<column name="userid" sql-type="char(32)" not-null="true"/>
<generator class="assigned"/>
</id>

<property name="email"/>
<property name="firstName"/>
<property name="lastName"/>
<property name="status"/>
<property name="address1" column="addr1" />
<property name="address2" column="addr2" />
<property name="city"/>
<property name="state"/>
<property name="zip"/>
<property name="country"/>
<property name="phone"/>

<join table="profile">

<key column="userid" property-ref="username"/>

<many-to-one name="bannerdata" class="org.springframework.samples.jpetstore.domain.Bannerdata" unique="true">
<column name="favcategory"/>
</many-to-one>

<property name="languagePreference" column="langpref"/>
<property name="bannerOption" column="banneropt"/>
<property name="listOption" column="mylistopt" />

</join>

<join table="signon">
<key column="username" property-ref="username"/>
<property name="password"/>
</join>

</class>
</hibernate-mapping>

Following error generated while loading hbm.xml


INFO: using JDK 1.4 java.sql.Timestamp handling
Mar 13, 2006 7:10:32 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.springframework.samples.jpetstore.domain.Bannerdata -> bannerdata
Mar 13, 2006 7:10:38 PM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(17) The content of element type "id" is incomplete, it must match "(meta*,column*,generator)".
Mar 13, 2006 7:10:38 PM org.springframework.beans.factory.support.AbstractBeanFactory destroySingletons
INFO: Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,dataSource,accountDao,categoryDao,productDao,itemDao,orderDao,sequenceDao,accountValidator,orderValidator,petStore,petstore:service=hibernateStatistics,jmxExporter]; root of BeanFactory hierarchy}
Mar 13, 2006 7:10:38 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/dataAccessContext-local.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: invalid mapping
org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:623)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:966)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:358)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:788)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:677)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:473)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Caused by: org.xml.sax.SAXParseException: The content of element type "id" is incomplete, it must match "(meta*,column*,generator)".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2048)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:932)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:713)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
... 35 more
Mar 13, 2006 7:10:38 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 13, 2006 7:10:38 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/jpetstore] startup failed due to previous errors




Can anybody help me out where I am going wrong?
or how it is to be done.

Regards,
Avinash

_________________
avinashb@cybage.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 12:40 pm 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Are you using hibernate 2 or 3 ?
Your mapping files have DTD of hibernate 2 !
But it looks like the spring framework is expecting 3:

Quote:
org.springframework.orm.hibernate3.LocalSessionFactoryBean



If this doesnt help, you can try to reduce you mappings until the error vanishes.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject: More than one
PostPosted: Sat Dec 09, 2006 1:34 pm 
Beginner
Beginner

Joined: Sat Dec 09, 2006 12:02 pm
Posts: 26
I have a question to this subject...
I have a database with more than one table. How can i map the resources without adding every file by hand???

Code:
      <property name="mappingResources">
         <list>
            <value>\model\Partner.hbm.xml</value>
            <!-- <value>Kunde.hbm.xml</value> -->
         </list>
      </property>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.