Hi,
I am having trouble defining a many to many table. I am currently modelling it as an object with a pair of attributes which compromise the primary key. However I am not getting very far. I get the following exception thrown during application startup.
Hibernate version: 3.1
Mapping documents
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="uk.co.dubit.nexus.roster.RosterMember" table="roster_members">
<property
name="owner"
column="owner"
type="int" />
<property
name="member"
column="member"
type="int" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():As yet, none. The mapping class is
Code:
public class RosterMember implements IPrimitiveEncodable
{
protected UserID owner_id;
protected UserID user_id;
private String name;
private RosterStatus status;
//More class related methods
/*============HIBERNATE ACCESS FUNCTIONS============*/
private RosterMember(){}
private long getOwnerId(){ return this.owner_id.key(); }
private void setOwnerId(long _id){this.owner_id = new UserID(_id); }
private long getUserId(){ return this.user_id.key(); }
private void setUserId(long _id){this.user_id = new UserID(_id); }
//More accessor functions
}
The rest of this gets pretty verbose now.
Full stack trace of any exception that occurs:
Quote:
org.hibernate.MappingException: Could not read mappings from resource: RosterMember.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at uk.co.dubit.nexus.db.HibernateManager.<init>(HibernateManager.java:23)
at uk.co.dubit.nexus.db.HibernateManager.getInstance(HibernateManager.java:30)
at uk.co.dubit.nexus.red5.Gateway.appStart(Gateway.java:27)
at org.red5.server.adapter.ApplicationAdapter.start(ApplicationAdapter.java:109)
at org.red5.server.Scope.start(Scope.java:110)
at org.red5.server.Scope.init(Scope.java:105)
at org.red5.server.WebScope.register(WebScope.java:90)
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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1092)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
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:275)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:318)
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.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:392)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:996)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:365)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:373)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:38)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:159)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:118)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:38)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:159)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:38)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:97)
at org.mortbay.jetty.Server.doStart(Server.java:194)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:38)
at org.red5.server.JettyLoader.init(JettyLoader.java:60)
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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1092)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
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:275)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:318)
at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:136)
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:386)
at org.red5.server.Standalone.main(Standalone.java:124)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:425)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 56 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
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.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(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:422)
... 57 more
Name and version of the database you are using: Postgres version 8.14The generated SQL (show_sql=true):None
Debug level Hibernate log excerpt:Quote:
[INFO] 3172 main:( org.hibernate.cfg.Environment.info ) Hibernate 3.1.3
[INFO] 3172 main:( org.hibernate.cfg.Environment.info ) hibernate.properties not found
[INFO] 3188 main:( org.hibernate.cfg.Environment.info ) using CGLIB reflection optimizer
[INFO] 3188 main:( org.hibernate.cfg.Environment.info ) using JDK 1.4 java.sql.Timestamp handling
[INFO] 3297 main:( org.hibernate.cfg.Configuration.info ) configuring from resource: /hibernate.cfg.xml
[INFO] 3297 main:( org.hibernate.cfg.Configuration.info ) Configuration resource: /hibernate.cfg.xml
[DEBUG] 3375 main:( org.hibernate.util.DTDEntityResolver.debug ) trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
[DEBUG] 3375 main:( org.hibernate.util.DTDEntityResolver.debug ) recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[DEBUG] 3375 main:( org.hibernate.util.DTDEntityResolver.debug ) located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.connection.driver_class=org.postgresql.Driver
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.connection.url=jdbc:postgresql://localhost/iTreasure_testing
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.connection.username=root
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.connection.password=population
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.c3p0.min_size=10
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.c3p0.max_size=20
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.c3p0.timeout=1800
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) hibernate.c3p0.max_statements=50
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) show_sql=true
[DEBUG] 3438 main:( org.hibernate.cfg.Configuration.debug ) null<-org.dom4j.tree.DefaultAttribute@1d33a6b [Attribute: name resource value "ChatroomSet.hbm.xml"]
[INFO] 3438 main:( org.hibernate.cfg.Configuration.info ) Reading mappings from resource: ChatroomSet.hbm.xml
[DEBUG] 3438 main:( org.hibernate.util.DTDEntityResolver.debug ) trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
[DEBUG] 3453 main:( org.hibernate.util.DTDEntityResolver.debug ) recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[DEBUG] 3453 main:( org.hibernate.util.DTDEntityResolver.debug ) located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
[INFO] 3578 main:( org.hibernate.cfg.HbmBinder.info ) Mapping class: uk.co.dubit.nexus.chat.ChatroomSet -> chat_sets
[DEBUG] 3594 main:( org.hibernate.cfg.HbmBinder.debug ) Mapped property: id -> id
[DEBUG] 3609 main:( org.hibernate.cfg.HbmBinder.debug ) Mapped property: namePattern -> name_pattern
[DEBUG] 3609 main:( org.hibernate.cfg.HbmBinder.debug ) Mapped property: capacity -> capacity
[DEBUG] 3625 main:( org.hibernate.cfg.Configuration.debug ) null<-org.dom4j.tree.DefaultAttribute@d58939 [Attribute: name resource value "User.hbm.xml"]
[INFO] 3625 main:( org.hibernate.cfg.Configuration.info ) Reading mappings from resource: User.hbm.xml
[DEBUG] 3625 main:( org.hibernate.util.DTDEntityResolver.debug ) trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
[DEBUG] 3625 main:( org.hibernate.util.DTDEntityResolver.debug ) recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[DEBUG] 3625 main:( org.hibernate.util.DTDEntityResolver.debug ) located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
[INFO] 3719 main:( org.hibernate.cfg.HbmBinder.info ) Mapping class: uk.co.dubit.nexus.user.User -> user_players
[DEBUG] 3719 main:( org.hibernate.cfg.HbmBinder.debug ) Mapped property: id -> player_id
[DEBUG] 3719 main:( org.hibernate.cfg.HbmBinder.debug ) Mapped property: name -> name
[DEBUG] 3719 main:( org.hibernate.cfg.HbmBinder.debug ) Mapped property: password -> password
[DEBUG] 3719 main:( org.hibernate.cfg.Configuration.debug ) null<-org.dom4j.tree.DefaultAttribute@93df2c [Attribute: name resource value "RosterMember.hbm.xml"]
[INFO] 3719 main:( org.hibernate.cfg.Configuration.info ) Reading mappings from resource: RosterMember.hbm.xml
[DEBUG] 3719 main:( org.hibernate.util.DTDEntityResolver.debug ) trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
[DEBUG] 3719 main:( org.hibernate.util.DTDEntityResolver.debug ) recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[DEBUG] 3719 main:( org.hibernate.util.DTDEntityResolver.debug ) located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
[/quote]