-->
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: Problem while loading hbm.xml
PostPosted: Fri Mar 03, 2006 5:00 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 3:26 am
Posts: 21
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hi,


Hibernate version:
using with spring


Mapping documents:

<class name = "org.springframework.samples.jpetstore.domain.Item" table = "item" lazy="false">
<id name="itemId" type="string" unsaved-value="null" >
<column name="itemid" sql-type="varchar" not-null="true"/>
<generator class="assigned"/>
</id>

<!--<one-to-one name="itemId" class="org.springframework.samples.jpetstore.domain.Inventory"/> -->




<join table="inventory">
<key column="itemid" property-ref="itemId"/>
<property name="quantity" column="qty"/>
</join>


<!--<one-to-one name="quantity" class="org.springframework.samples.jpetstore.domain.Inventory"/>-->

<many-to-one name="product" class="org.springframework.samples.jpetstore.domain.Product">
<column name="productid" />
</many-to-one>

<property name="productId" column="productid" insert="false" update="false"/>
<property name="supplierId" column="supplier"/>
<property name="listPrice" column="listprice" />
<property name="unitCost" column="unitcost" />
<property name="status" />
<property name="attribute1" column="attr1"/>
<property name="attribute2" column="attr2"/>
<property name="attribute3" column="attr3"/>
<property name="attribute4" column="attr4"/>
<property name="attribute5" column="attr5"/>

</class>



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Mar 3, 2006 2:16:37 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-9080
Mar 3, 2006 2:16:37 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1016 ms
Mar 3, 2006 2:16:37 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 3, 2006 2:16:37 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.9
Mar 3, 2006 2:16:37 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Mar 3, 2006 2:16:38 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive jpetstore.war
Mar 3, 2006 2:16:38 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Mar 3, 2006 2:16:39 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dataAccessContext-local.xml]
Mar 3, 2006 2:16:39 PM org.springframework.core.CollectionFactory <clinit>
INFO: JDK 1.4+ collections available
Mar 3, 2006 2:16:39 PM org.springframework.core.CollectionFactory <clinit>
INFO: Commons Collections 3.x available
Mar 3, 2006 2:16:39 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]
Mar 3, 2006 2:16:39 PM org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [Root WebApplicationContext]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,dataSource,accountDao,categoryDao,productDao,itemDao,orderDao,accountValidator,orderValidator,petStore,petstore:service=hibernateStatistics,jmxExporter]; root of BeanFactory hierarchy
Mar 3, 2006 2:16:39 PM org.springframework.context.support.AbstractApplicationContext refresh
INFO: 14 beans defined in application context [Root WebApplicationContext]
Mar 3, 2006 2:16:39 PM org.springframework.beans.factory.support.AbstractBeanFactory getBean
INFO: Creating shared instance of singleton bean 'propertyConfigurer'
Mar 3, 2006 2:16:39 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from ServletContext resource [/WEB-INF/jdbc.properties]
Mar 3, 2006 2:16:39 PM org.springframework.context.support.AbstractApplicationContext initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@1f03691]
Mar 3, 2006 2:16:39 PM org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@1ce85c4]
Mar 3, 2006 2:16:39 PM org.springframework.ui.context.support.UiApplicationContextUtils initThemeSource
INFO: No ThemeSource found for [Root WebApplicationContext]: using ResourceBundleThemeSource
Mar 3, 2006 2:16:39 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,dataSource,accountDao,categoryDao,productDao,itemDao,orderDao,accountValidator,orderValidator,petStore,petstore:service=hibernateStatistics,jmxExporter]; root of BeanFactory hierarchy]
Mar 3, 2006 2:16:39 PM org.springframework.beans.factory.support.AbstractBeanFactory getBean
INFO: Creating shared instance of singleton bean 'sessionFactory'
Mar 3, 2006 2:16:39 PM org.springframework.beans.factory.support.AbstractBeanFactory getBean
INFO: Creating shared instance of singleton bean 'dataSource'
Mar 3, 2006 2:16:39 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.4
Mar 3, 2006 2:16:39 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Mar 3, 2006 2:16:39 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Mar 3, 2006 2:16:39 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Mar 3, 2006 2:16:40 PM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(104) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*)".
Mar 3, 2006 2:16:40 PM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(113) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*)".
Mar 3, 2006 2:16:40 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,accountValidator,orderValidator,petStore,petstore:service=hibernateStatistics,jmxExporter]; root of BeanFactory hierarchy}
Mar 3, 2006 2:16:40 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 "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*)".
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 3, 2006 2:16:40 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 3, 2006 2:16:40 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/jpetstore] startup failed due to previous errors
Mar 3, 2006 2:16:41 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-9080
Mar 3, 2006 2:16:41 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:9009
Mar 3, 2006 2:16:41 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31 config=null
Mar 3, 2006 2:16:41 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Mar 3, 2006 2:16:41 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4047 ms




Name and version of the database you are using:

mysql 4.0


The generated SQL (show_sql=true):
hbm.xml not getting loaded.



Debug level Hibernate log excerpt:

Please note that I get this error when I added this code in hbm.xml

<join table="inventory">
<key column="itemid" property-ref="itemId"/>
<property name="quantity" column="qty"/>
</join>

without these lines of code the hbm.xml was getting loaded properly.

I have qty column in inventory table.
I have Item.java which has setQuantity() & I do not have inventory class.

I want to set the quantity from inventory table to item class.
So can anybody help me how to do it.????

Regards,
Avinash

_________________
avinashb@cybage.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 6:00 am 
Beginner
Beginner

Joined: Wed Aug 04, 2004 4:33 am
Posts: 45
Location: Switzerland
Try put join at the end, like this:

<class name = "org.springframework.samples.jpetstore.domain.Item" table = "item" lazy="false">
<id name="itemId" type="string" unsaved-value="null" >
<column name="itemid" sql-type="varchar" not-null="true"/>
<generator class="assigned"/>
</id>

<!--<one-to-one name="itemId" class="org.springframework.samples.jpetstore.domain.Inventory"/> -->



<!--<one-to-one name="quantity" class="org.springframework.samples.jpetstore.domain.Inventory"/>-->

<many-to-one name="product" class="org.springframework.samples.jpetstore.domain.Product">
<column name="productid" />
</many-to-one>

<property name="productId" column="productid" insert="false" update="false"/>
<property name="supplierId" column="supplier"/>
<property name="listPrice" column="listprice" />
<property name="unitCost" column="unitcost" />
<property name="status" />
<property name="attribute1" column="attr1"/>
<property name="attribute2" column="attr2"/>
<property name="attribute3" column="attr3"/>
<property name="attribute4" column="attr4"/>
<property name="attribute5" column="attr5"/>


<join table="inventory">
<key column="itemid" property-ref="itemId"/>
<property name="quantity" column="qty"/>
</join>

</class>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 6:11 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 3:26 am
Posts: 21
Hi,

you are right

My problem was solved when I put the join tag at the end.


Regards,
Avinash

_________________
avinashb@cybage.com


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.