-->
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.  [ 4 posts ] 
Author Message
 Post subject: [ Hibernate Tools ] Attribute lazy must be declared...
PostPosted: Fri Apr 15, 2005 10:02 am 
Beginner
Beginner

Joined: Wed Mar 30, 2005 5:41 am
Posts: 40
Hi,

I have the mapping file below. It works with my code, it is validated ok by eclipse but when I try to use the Hibernate Tools plugin for eclipse, it failed :

org.hibernate.MappingException: Error reading resource: bab/admin/model/persistent/Job.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:444)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1369)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1341)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1323)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1290)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1252)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:151)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:128)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:50)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2894)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2527)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1570)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1534)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:306)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:228)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:315)
at org.eclipse.core.launcher.Main.basicRun(Main.java:268)
at org.eclipse.core.launcher.Main.run(Main.java:942)
at org.eclipse.core.launcher.Main.main(Main.java:926)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:391)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:441)
... 33 more
Caused by: org.xml.sax.SAXParseException: Attribute "lazy" must be declared for element type "many-to-one".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:334)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:390)
... 34 more


I cant understand the problem, my mapping file is correct and I have put lazy attributes to all my many-to-one elements :

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
<class name="bab.admin.model.persistent.Job" table="t_service"
dynamic-update="false" dynamic-insert="false"
select-before-update="false" optimistic-lock="version">

<id name="id" column="serviceId" type="java.lang.Integer">
<generator class="native">
</generator>
</id>

<many-to-one
name="client"
column="clientPartyId"
lazy="false" />
<many-to-one
name="contactForBAB"
column="employeePartyId"
lazy="false" />

<many-to-one
name="contactForClient"
column="clientResponsiblePartyId"
class="bab.admin.model.persistent.Contact"
cascade="save-update"
lazy="false" />

<many-to-one
name="tarif"
column="tarifId"
cascade="all"
lazy="false" />

<one-to-one name="evaluation" />
<one-to-one name="address" />

<property name="fileId" />
<property
name="title"
column="jobTitle" />
<property
name="description"
column="jobDescription" />
<property
name="begin"
column="contactDate" />
<property
name="close"
column="closeDate" />
<property
name="contract"
column="contractDate" />
<property
name="feedback"
column="babFeedback" />

<component name="invoice">

<property
name="sent"
column="invoiceDate" />
<property
name="number"
column="invoiceNumber" />
<property name="comment" />
<property name="otherCharges" />
<property name="otherChargesDescription" />

</component>




</class>

</hibernate-mapping>

What should I do ?
Thank you
best regards
Lilian


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 15, 2005 3:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
does it work when you use them directly by hibernate ?

try to update to the latest hibernate tools and see if the issue persists...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 4:16 am 
Beginner
Beginner

Joined: Wed Mar 30, 2005 5:41 am
Posts: 40
max wrote:
does it work when you use them directly by hibernate ?

try to update to the latest hibernate tools and see if the issue persists...


Thank you for your answer, yes it works well when I use my mappings directly by hibernate.

I think I have the latest version of hibernate tools (alpha1).

Regards
Lilian


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 8:04 am 
Newbie

Joined: Fri Jun 03, 2005 7:46 am
Posts: 1
I’m experiencing the same problem when trying to use the latest Hibernate Tools for browsing an already existing project. (hibernate-tools-3.0alpha1.tar.gz)
When creating the SessionFactory under ‘Hibernate Configurations’ I’ll get the described MappingException.

Code:
Caused by: org.hibernate.MappingException: invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:391)
   at org.hibernate.cfg.Configuration.addFile(Configuration.java:238)
   ... 27 more
Caused by: org.xml.sax.SAXParseException: Attribute "lazy" is not declared for element "many-to-one".
   at org.apache.crimson.parser.Parser2.error(Unknown Source)
   at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
   at org.apache.crimson.parser.Parser2.content(Unknown Source)
   at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
   at org.apache.crimson.parser.Parser2.content(Unknown Source)
   at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
   at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
   at org.apache.crimson.parser.Parser2.parse(Unknown Source)
   at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:334)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:390)
   ... 28 more


The Hibernate mappings work fine in the existing project.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.