HIBERNATE pode várias Interfaces?

Salve Salve Galera.

Tenho um problema q muito me aflinge e desespera :oops:

Consegui criar uma aplicação simples em hibernate :lol: onde a minha classe Cachorro e Gato implementam Mamifero, tenho no banco as 3 tabelas (Cachorro,Gato e Mamifero) onde Mamifero possui campos q sao comuns a Cachorro e Gato. Porem tentei criar uma outra Interface alem da Mamifero chamada Felino e fazer Gato implementar dela. Só q o Hibernate não aceita, da erro (duplicate import Gato) ja no createFactorySession(). Vale lembrar q estou usando a estrategia <join-subclasse>

:!:
ps.: tenho dois mappings, um pra Mamifero e outro pra Felino.

SERA ISSO UMA LIMITAÇÃO DO ROBUSTO FRAMEWORK HIBERNATE?

Valew :wink:

Nao eh limitação nao… da pra fazer vááááários niveis de herança com o hibernate. Explica um pouquinho melhor a sua estratégia, com um pouco mais de detalhes…

resumindo: n é herança q me refiro e sim implementaçao de interface, n consigo implementar de 2 interfaces, no meu exemplo o hibernate funciona qdo Gato implementa ou Mamiferi ou Felino, ou exclusivo saca? queria poder implementar das 2 ao memos tempo

DETALHES, la vai detalhes:

segue meu cfg

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE hibernate-configuration PUBLIC
		&quot;-//Hibernate/Hibernate Configuration DTD 3.0//EN&quot;
		&quot;http&#58;//hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;&gt;
&lt;hibernate-configuration&gt;
    &lt;session-factory&gt;

        &lt;!-- POSTGRES --&gt;
     &lt;!--   &lt;property name=&quot;hibernate.connection.url&quot;&gt;jdbc&#58;postgresql&#58;//10.0.0.7&#58;5432/test_hibernate&lt;/property&gt;
        &lt;property name=&quot;hibernate.cglib.use_reflection_optimizer&quot;&gt;true&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.password&quot;&gt;1234&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.username&quot;&gt;postgres&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.driver_class&quot;&gt;org.postgresql.Driver&lt;/property&gt;
        &lt;property name=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/property&gt;    --&gt;

        &lt;!-- MYSQL --&gt;
        &lt;property name=&quot;hibernate.connection.url&quot;&gt;jdbc&#58;mysql&#58;//localhost&#58;3306/srh&lt;/property&gt;
        &lt;property name=&quot;hibernate.cglib.use_reflection_optimizer&quot;&gt;true&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.password&quot;&gt;root&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.username&quot;&gt;root&lt;/property&gt;
        &lt;property name=&quot;hibernate.connection.driver_class&quot;&gt;org.gjt.mm.mysql.Driver&lt;/property&gt;
        &lt;property name=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
        
    	&lt;mapping resource=&quot;testpackage/Felino.hbm.xml&quot;/&gt; 
               &lt;mapping resource=&quot;testpackage/Mamifero.hbm.xml&quot;/&gt;   	     
		
    &lt;/session-factory&gt;
&lt;/hibernate-configuration&gt;

Mamifero.hbm.xml

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE hibernate-mapping PUBLIC
	&quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&quot;
	&quot;http&#58;//hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&gt;

&lt;hibernate-mapping&gt;

&lt;class name=&quot;testpackage.Mamifero&quot;&gt;

 &lt;id name=&quot;id&quot; column=&quot;ID&quot; type=&quot;long&quot;&gt; 
             &lt;generator class=&quot;increment&quot;/&gt; 
          &lt;/id&gt; 
          
          &lt;property name=&quot;lastName&quot; column=&quot;LAST_NAME&quot;/&gt;
          &lt;property name=&quot;firstName&quot; column=&quot;FIRST_NAME&quot;/&gt;                  
	
	    &lt;union-subclass name=&quot;testpackage.Gato&quot; table=&quot;GATO&quot;&gt;
          &lt;property name=&quot;age&quot; column=&quot;AGE&quot;/&gt;   
        &lt;/union-subclass&gt;
        
        &lt;union-subclass name=&quot;testpackage.Cachorro&quot; table=&quot;CACHORRO&quot;&gt;
          &lt;property name=&quot;nome&quot; column=&quot;NOME&quot;/&gt;
        &lt;/union-subclass&gt;
	
&lt;/class&gt;
&lt;/hibernate-mapping&gt;

Felino.hbm.xml

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE hibernate-mapping PUBLIC
	&quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&quot;
	&quot;http&#58;//hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&gt;

&lt;hibernate-mapping&gt;


&lt;class name=&quot;testpackage.Felino&quot;&gt;

          &lt;id name=&quot;id&quot; column=&quot;ID&quot; type=&quot;long&quot;&gt; 
             &lt;generator class=&quot;increment&quot;/&gt; 
          &lt;/id&gt; 
          
          &lt;property name=&quot;raca&quot; column=&quot;RACA&quot;/&gt;
          &lt;property name=&quot;familia&quot; column=&quot;FAMILIA&quot;/&gt;                  
	
	    &lt;union-subclass name=&quot;testpackage.Gato&quot; table=&quot;GATO&quot;&gt;
          &lt;property name=&quot;age&quot; column=&quot;AGE&quot;/&gt;   
        &lt;/union-subclass&gt;	
	
&lt;/class&gt;
&lt;/hibernate-mapping&gt;

No cfg onde tem:

   	&lt;mapping resource=&quot;testpackage/Felino.hbm.xml&quot;/&gt; 
               &lt;mapping resource=&quot;testpackage/Mamifero.hbm.xml&quot;/&gt;   

se eu deixar os dois descomentado da o seguinte erro qdo tem criar a Session Factory

org.hibernate.MappingException&#58; Error reading resource&#58; testpackage/Mamifero.hbm.xml
	at org.hibernate.cfg.Configuration.addResource&#40;Configuration.java&#58;444&#41;
	at org.hibernate.cfg.Configuration.parseMappingElement&#40;Configuration.java&#58;1369&#41;
	at org.hibernate.cfg.Configuration.parseSessionFactory&#40;Configuration.java&#58;1341&#41;
	at org.hibernate.cfg.Configuration.doConfigure&#40;Configuration.java&#58;1323&#41;
	at org.hibernate.cfg.Configuration.doConfigure&#40;Configuration.java&#58;1290&#41;
	at org.hibernate.cfg.Configuration.configure&#40;Configuration.java&#58;1252&#41;
	at org.hibernate.console.ConsoleConfiguration.buildWith&#40;ConsoleConfiguration.java&#58;151&#41;
	at org.hibernate.console.ConsoleConfiguration.build&#40;ConsoleConfiguration.java&#58;128&#41;
	at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun&#40;BuildSessionFactoryAction.java&#58;50&#41;
	at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run&#40;ConsoleConfigurationBasedAction.java&#58;47&#41;
	at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent&#40;BaseSelectionListenerAction.java&#58;166&#41;
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection&#40;ActionContributionItem.java&#58;915&#41;
	at org.eclipse.jface.action.ActionContributionItem.access$2&#40;ActionContributionItem.java&#58;866&#41;
	at org.eclipse.jface.action.ActionContributionItem$7.handleEvent&#40;ActionContributionItem.java&#58;785&#41;
	at org.eclipse.swt.widgets.EventTable.sendEvent&#40;EventTable.java&#58;82&#41;
	at org.eclipse.swt.widgets.Widget.sendEvent&#40;Widget.java&#58;796&#41;
	at org.eclipse.swt.widgets.Display.runDeferredEvents&#40;Display.java&#58;2773&#41;
	at org.eclipse.swt.widgets.Display.readAndDispatch&#40;Display.java&#58;2432&#41;
	at org.eclipse.ui.internal.Workbench.runEventLoop&#40;Workbench.java&#58;1377&#41;
	at org.eclipse.ui.internal.Workbench.runUI&#40;Workbench.java&#58;1348&#41;
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench&#40;Workbench.java&#58;254&#41;
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench&#40;PlatformUI.java&#58;141&#41;
	at org.eclipse.ui.internal.ide.IDEApplication.run&#40;IDEApplication.java&#58;96&#41;
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run&#40;PlatformActivator.java&#58;335&#41;
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run&#40;EclipseStarter.java&#58;273&#41;
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run&#40;EclipseStarter.java&#58;129&#41;
	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
	at org.eclipse.core.launcher.Main.basicRun&#40;Main.java&#58;185&#41;
	at org.eclipse.core.launcher.Main.run&#40;Main.java&#58;704&#41;
	at org.eclipse.core.launcher.Main.main&#40;Main.java&#58;688&#41;
Caused by&#58; org.hibernate.MappingException&#58; &#91;b&#93;duplicate import&#58; testpackage.Gato&#91;/b&#93;
	at org.hibernate.cfg.Mappings.addImport&#40;Mappings.java&#58;99&#41;
	at org.hibernate.cfg.HbmBinder.bindClass&#40;HbmBinder.java&#58;157&#41;
	at org.hibernate.cfg.HbmBinder.bindUnionSubclass&#40;HbmBinder.java&#58;309&#41;
	at org.hibernate.cfg.HbmBinder.handleUnionSubclass&#40;HbmBinder.java&#58;1535&#41;
	at org.hibernate.cfg.HbmBinder.createClassProperties&#40;HbmBinder.java&#58;1472&#41;
	at org.hibernate.cfg.HbmBinder.bindRootClass&#40;HbmBinder.java&#58;579&#41;
	at org.hibernate.cfg.HbmBinder.bindRoot&#40;HbmBinder.java&#58;1787&#41;
	at org.hibernate.cfg.Configuration.add&#40;Configuration.java&#58;355&#41;
	at org.hibernate.cfg.Configuration.addInputStream&#40;Configuration.java&#58;392&#41;
	at org.hibernate.cfg.Configuration.addResource&#40;Configuration.java&#58;441&#41;
	... 32 more

Se eu deixar so o Felino ou só o Mamifero na cfg funciona beleza, porém qdo deixo os dois da esse pau :roll:

ESTOU DESESPERADO, SErÁ UMA LIMITAçÂO DO ROBUSTO HIBERNATE:!:!:!:!:!:! acho q sim

se n, é um desafio pra nois :wink: [/b]

valew pela a atencao, pensei q meu topico ia morfar aqui :lol:

espero q tenha entendido minha duvida :oops:

acho q entendi sim… bom, vc pode contornar isso fazendo herança…

                          Animal
                               |
                        MAMIFERO
                               |
                           ______
                          |          |
                     FELINO  CANINO

Será q vc pode fazer assim?!