I have a class : com.seanergie.authentication.Role, and a subclass com.platre.authentication.Role
So, in my hibernate-mapping document, H vabe a <class name="com.seanergie.authentication.Role"> that holds a <subclass name="com.platre.authentication.Role">.
The full mapping document is bellow.
This generates a MappingException: duplicate import: Role
The full stack trace is bellow.
But if the subclass has a slightly different name, like com.platre.authentication.Role
Z, then everything works fine.
It seems that hibernate doesn't uses the full qualified class name, and that leads to this duplicate import.
Is it forbidden to have a subclass having the same name as the parent class, even if the fully qualified names are different ?
More generally, what precaution should we use regarding class names ?
Hibernate version: 2.1.6
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping>
<class
name="com.seanergie.authentication.Role"
table="roles"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>
<id
name="unid"
column="unid"
type="java.lang.String"
>
<generator class="uuid.hex">
</generator>
</id>
<discriminator
column="roleClass"
type="string"
/>
<version
name="version"
type="int"
column="version"
access="property"
unsaved-value="undefined"
/>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="name"
/>
<set
name="accesses"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
>
<key
column="role"
>
</key>
<one-to-many
class="com.seanergie.authentication.RoleAccess"
/>
</set>
<subclass
name="com.platre.authentication.Role"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="role"
>
</subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Full stack trace of any exception that occurs:Code:
INFO: Mapping resource: com/seanergie/authentication/Role.hbm.xml
Oct 29, 2004 12:35:29 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.seanergie.authentication.Role -> roles
Oct 29, 2004 12:35:29 PM net.sf.hibernate.cfg.Configuration add
SEVERE: Could not compile the mapping document
net.sf.hibernate.MappingException: duplicate import: Role
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindSubclass(Binder.java:161)
at net.sf.hibernate.cfg.Binder.handleSubclass(Binder.java:1094)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1055)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:362)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1013)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:883)
at com.seanergie.persistence.SessionsManager.initialise(SessionsManager.java:45)
at com.seanergie.filter.persistence.SessionsManagerFilter.init(SessionsManagerFilter.java:33)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:225)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:79)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3468)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4037)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:755)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:590)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:493)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1156)
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.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1411)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:813)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:345)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:524)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Name and version of the database you are using:
Postgresql 7.3