-->
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.  [ 1 post ] 
Author Message
 Post subject: Attribute "not-found" must be declared for element
PostPosted: Thu Sep 18, 2008 1:13 pm 
Newbie

Joined: Sat May 03, 2008 12:30 pm
Posts: 9
Hi,
When I try to load the following hbm file I get this exception.

- Error parsing XML: XML InputStream(40) Attribute "not-found" must be declared for element type "many-to-one".

I checked the hbm file and it has not-found attribute specified and I also observe that that not-found clause in hibernate has a default value also.

Can you please guide me?
###################

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3 H

Mapping documents:

Code between sessionFactory.openSession() and session.close():
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object
tx=session.beginTransaction();
session.save(analyst);
tx.commit();
System.out.println("Done");
}catch(Exception e){
result=false;
System.out.println(e.getMessage());
System.out.println("User not saved in MIS");
e.printStackTrace();
}finally{
// Actual contact insertion will happen at this step
session.flush();

session.close();

}

Full stack trace of any exception that occurs:


- Error parsing XML: XML InputStream(40) Attribute "not-found" must be declared for element type "many-to-one".
- Error parsing XML: XML InputStream(43) Attribute "not-found" must be declared for element type "many-to-one".
- Error parsing XML: XML InputStream(46) Attribute "not-found" must be declared for element type "one-to-many".
Error reading resource: sw\hbm\analyst.hbm.xml
User not saved in MMIS
org.hibernate.MappingException: Error reading resource: \sw\hbm\analyst.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:447)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1381)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1353)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1335)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1302)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1230)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1216)
at SecurityIdLoad.createUserInMMIS(SecurityIdLoad.java:203)
at SecurityIdLoad.addUserAndRole(SecurityIdLoad.java:104)
at SecurityIDLoad.SecurityIdLoadClient.main(SecurityIdLoadClient.java:16)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:394)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:444)
... 9 more
Caused by: org.xml.sax.SAXParseException: Attribute "not-found" must be declared for element type "many-to-one".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:334)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:393)
... 10 moreName and version of the database you are using:

The generated SQL (show_sql=true):
oracle 10

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html
#####################

analyst.hbm.xml

#####################

<?xml version="1.0" ?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="sw.model" default-cascade="all" default-access="property" default-lazy="true" auto-import="true" schema="AIM">


<class name="Analystl" table="T_ANALYST" polymorphism="explicit">

<id name="clerkID" type="gov.ma.eohhs.newmmis.base.usertypes.MMISStringTrim">
<column name="ID_CLERK" not-null="true" length="8" sql-type="string" />
<generator class="select">
<param name="key">userName</param>
</generator>
</id>
<version column="ID_VERSION_LOCK" name="version" type="integer" unsaved-value="null"/>
<property name="domain" column="NAM_DOMAIN" type="string" not-null="true" length="67" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="userName" column="NAME_USER" type="string" not-null="true" length="32"
unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="firstName" column="NAM_FIRST" type="string" not-null="true" length="13" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="lastName" column="NAM_LAST" type="string" not-null="true" length="15" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="midInitialName" column="NAM_MID_INIT" type="string" not-null="false" length="1" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="cdeStatus" column="CDE_STATUS" type="string" not-null="true" length="1" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="email" column="ADR_EMAIL" type="string" not-null="false" length="50" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="pagerNumber" column="NUM_PAGER" type="string" not-null="false" length="50" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="phoneNumber" column="NUM_PHONE" type="string" not-null="false" length="10" unique="false" update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="verificationField" column="TXT_VERIFICATION" type="string" not-null="true" length="4" unique="false"
update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="dateOfBirth" column="TXT_DOB" type="string" not-null="true" length="4" unique="false"
update="true" insert="true" optimistic-lock="true" lazy="false"/>
<property name="zipCode" column="ZIP" type="string" not-null="false" length="5" unique="false"
update="true" insert="true" optimistic-lock="true" lazy="false"/>
<many-to-one name="cdePreferNotifType" class="messaging.model.MessageType"
column="CDE_PREFER_NOTIF_TYPE" not-null="false" unique="false" update="true" insert="true"
optimistic-lock="true" embed-xml="true" cascade="none" not-found="ignore" />
<many-to-one name="analystType" class="gov.ma.eohhs.newmmis.sw.model.AnalystType" column="CDE_ANALYST_TYPE"
not-null="false" unique="false" update="true" insert="true" optimistic-lock="true" embed-xml="true"
cascade="none" not-found="ignore" />
<bag name="userRoleList" inverse="true" optimistic-lock="true" cascade="all,delete-orphan" lazy="true" batch-size="10" fetch="join">
<key column="ID_CLERK" on-delete="noaction" />
<one-to-many class="AuthUserRoleEx" not-found="ignore" />
</bag>
<bag name="analystMemberList" inverse="true" lazy="true" optimistic-lock="true" cascade="all,delete-orphan" batch-size="4" fetch="select">
<key column="ID_CLERK" on-delete="noaction"/>
<one-to-many class="sw.model.AnalystMembers" />
</bag>
<bag name="analystProviderList" inverse="true" lazy="true" optimistic-lock="true" cascade="all,delete-orphan" batch-size="4" fetch="select">
<key column="ID_CLERK" on-delete="noaction"/>
<one-to-many class="sw.model.AnalystProviders" />
</bag>
<one-to-one name="consultantId" class="ConsultantId" constrained="false" embed-xml="true"
cascade="save-update" property-ref="ClerkId" />
</class>
</hibernate-mapping>


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

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.