-->
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.  [ 6 posts ] 
Author Message
 Post subject: duplicate import problem with homonymous subclass
PostPosted: Fri Oct 29, 2004 2:07 pm 
Beginner
Beginner

Joined: Sun Aug 29, 2004 7:21 pm
Posts: 26
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.RoleZ, 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


Top
 Profile  
 
 Post subject: Same problem, even when changing the discriminator-value
PostPosted: Thu Nov 11, 2004 2:32 pm 
Newbie

Joined: Thu Nov 11, 2004 2:28 pm
Posts: 4
Hi Sylvain,

I am having exactly the same issue. I tried to change the discriminator-value in one of the mapping, but this doesn't help. Have you made any progress on that issue on your side ?

Greetings,
R


Top
 Profile  
 
 Post subject: No progress
PostPosted: Thu Nov 11, 2004 3:13 pm 
Beginner
Beginner

Joined: Sun Aug 29, 2004 7:21 pm
Posts: 26
Sorry, no, I didn't make any progress except on deciding to stop using classes with the same name.

Until now, it's ok, but I hope we will have a fix or a clarification before the projects becomes too big.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 3:15 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please post this to JIRA.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2004 1:30 am 
Regular
Regular

Joined: Fri Nov 12, 2004 12:07 am
Posts: 57
Location: Beijing,China
<hibernate-config
.....
auto-import=false>

should be ok!


Top
 Profile  
 
 Post subject: Solves the problem
PostPosted: Thu Apr 21, 2005 5:11 pm 
Beginner
Beginner

Joined: Sun Aug 29, 2004 7:21 pm
Posts: 26
amjn wrote:
<hibernate-config
.....
auto-import=false>

should be ok!


Sorry, I just saw your reply !
It solves the problem. Thank you.


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