-->
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.  [ 2 posts ] 
Author Message
 Post subject: "column" must be declared for element type "o
PostPosted: Tue Sep 27, 2005 3:19 pm 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hi, Could anyone offer any advise on the following issue. I have a class (ApplicationImpl)which has a M:M relationship with AuditEventTypes (TrAuditEventTypeVO) and a 1:M relationship with classified errors (ErrorEventVO). If I comment out the 1:M relationship with Errors, then the code functions fine. But when I include the 1:M relationship I get an error of
Quote:
ERROR XMLHelper:59 - Error parsing XML: XML InputStream(24) Attribute "column" must be declared for element type "one-to-many".


But the Hibernate mapping DTD notes that on one_to_many relationships...
Quote:
<!ELEMENT one-to-many EMPTY>
<!ATTLIST one-to-many class CDATA #IMPLIED>
<!ATTLIST one-to-many not-found (exception|ignore) "exception">
<!ATTLIST one-to-many node CDATA #IMPLIED>
<!ATTLIST one-to-many embed-xml (true|false) "true">
<!ATTLIST one-to-many entity-name CDATA #IMPLIED>
<!-- No column declaration attributes required in this case. The primary
key column of the associated class is already mapped elsewhere.-->


Including the column does not seem to fix the problem. Considering that the error rows contain a foreign key to the application, it seems odd to have a column defined on the 1:m relationship.

Any help would be greatly appreciated... Oh, If you haven't noticed, I'm fairly new to Hibernate, but I have read the information regarding 1:M relationships and infact the reference in
Quote:
8.2.3. one to many

does not utilize a column name on the one_to_many definition.

Hibernate version:3.0.5

Mapping documents:
ApplicationImpl.hbm.xml contents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="j3_foundations_dba" default-lazy="false">
<class name="com.thomson.west.foundations.context.ApplicationImpl" table="application">
<id name="appName" column="app_name">
</id>
<property name="dispName" type="string" column="disp_name"/>
<property name="deptName" type="string" column="department"/>
<property name="description" type="string" column="description"/>
<property name="authenticateVia" column="authenticate_via"/>
<!-- set eventTypes hooked to this application -->
<set name="eventTypes" table="app_event">
<key column="app_name"/>
<many-to-many column="event_type_id" class="com.thomson.west.foundations.traudit.TrAuditEventTypeVO"/>
</set>
<!-- set of classified errors hooked to this application -->
<set name="classifiedErrors" schema="j3_foundations_dba" table="error_def" inverse="true" cascade="all-delete-orphan">
<key column="error_def_id"/>
<one-to-many column="app_name" class="com.thomson.west.foundations.ErrorEventVO"/>
</set>
</class>
</hibernate-mapping>

TrAuditEventTypeVO.hbm.xml contents...
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="j3_foundations_dba">
<class name="com.thomson.west.foundations.traudit.TrAuditEventTypeVO" table="event_type">
<id name="EventTypeId" column="event_type_id">
<generator class="increment"/>
</id>
<property name="EventTypeName" type="string" column="event_type_name"/>
<property name="EventTypeDesc" type="string" column="event_type_description"/>
</class>
</hibernate-mapping>

ErrorEventVO.hbm.xml contents...
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="j3_foundations_dba">
<class name="com.thomson.west.foundations.error.ErrorEventVO" table="error_def">
<id name="errorDefId" column="error_def_id">
<generator class="increment"/>
</id>
<property name="errorName" type="string" column="error_name"/>
<property name="errorDesc" type="string" column="error_description"/>
<property name="priorityValue" type="integer" column="priority"/>
<property name="globalType" type="string" column="global_type"/>
<property name="globalSubType" type="string" column="global_sub_type"/>
<property name="globalWFService" type="string" column="global_wf_service"/>
<property name="scope" type="integer" column="scope"/>
<property name="userMessage" type="string" column="user_message"/>
<property name="notifyMessage" type="string" column="notify_message"/>
<property name="interestedPartyListStr" type="string" column="interested_parties"/>
<property name="notifySysString" type="string" column="notify_system_list"/>
<property name="createTask" type="character" column="create_task"/>
<property name="notifyInterestedParties" type="character" column="notify_interested_parties"/>
<property name="notifySystems" type="character" column="notify_systems"/>
<property name="routeTo" type="string" column="route_to"/>
<!-- <property name="appName" type="string" column="app_name"/> -->
<!-- <many-to-one name="appName" column="app_name" not-null="true"/> -->
<property name="environment" type="string" column="environment"/>
<property name="serverName" type="string" column="server_name"/>
<property name="trackError" type="character" column="tracked_error"/>
<property name="systemError" type="character" column="system_error"/>
<property name="suspendRecording" type="character" column="suspend_recording"/>
</class>
</hibernate-mapping>

Hibernate.cfg.xml contents...
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<hibernate-configuration>
<session-factory>
... REALLY BIG SNIP...

<mapping resource="ErrorEventVO.hbm.xml"/>
<mapping resource="ApplicationImpl.hbm.xml"/>
<mapping resource="TrAuditEventTypeVO.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():
Never really get here. as the exception is thrown in .buildSessionFactory

Full stack trace of any exception that occurs:
Initial SessionFactory creation failed.org.hibernate.MappingException: Error reading resource: ApplicationImpl.hbm.xml
org.hibernate.MappingException: Error reading resource: ApplicationImpl.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at com.thomson.west.foundations.daos.HibernateUtil.<clinit>(HibernateUtil.java:43)
at com.thomson.west.foundations.daos.DBDAO.<init>(DBDAO.java:52)
at com.thomson.west.foundations.daos.DBDAOFactory.createDAO(DBDAOFactory.java:57)
at com.thomson.west.foundations.daos.DAOFactoryBuilder.getRetrievalDAO(DAOFactoryBuilder.java:107)
at com.thomson.west.foundations.context.ApplicationImpl.retrieveApp(ApplicationImpl.java:114)
at com.thomson.west.foundations.context.ApplicationImpl.loadApp(ApplicationImpl.java:89)
at com.thomson.west.foundations.context.ApplicationImpl.<init>(ApplicationImpl.java:81)
at com.thomson.west.foundations.FoundationsBuilder.eagerPopulate(FoundationsBuilder.java:107)
at com.thomson.west.foundations.FoundationsBuilder.<init>(FoundationsBuilder.java:98)
at com.thomson.west.foundations.security.test.FoundationsSampleSecurityUseageTestEnv.runApp(FoundationsSampleSecurityUseageTestEnv.java:91)
at com.thomson.west.foundations.security.test.FoundationsSampleSecurityUseageTestEnv.main(FoundationsSampleSecurityUseageTestEnv.java:79)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 17 more
Caused by: org.xml.sax.SAXParseException: Attribute "column" must be declared for element type "one-to-many".
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:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
... 18 more

Name and version of the database you are using:
Oracle 10g (I think the g is correct)

The generated SQL (show_sql=true):
None

Debug level Hibernate log excerpt:

Quote:
Quote:

Thanks in advance for any assistence you can provide.


_________________
Dave Ziebol


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 3:49 pm 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
Ok, got it.

on a one_to_many the <key column= > referred to is the key of the link between the tables, not the key of the associtaged table. Hence I priviously had

Code:
<key column="error_def_id"/>


error_def_id being the key for the ErrorDef Table. This should be

Code:
<key column="app_name"/>


which is the column to link on given that the application (the one side in the 1:M relationship has a key of app_name...

I found this in the reference docs under 24.3. Customer/Order/Product

Thanks anyways

_________________
Dave Ziebol


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