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
<?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>
<!-- POSTGRES -->
<!-- <property name="hibernate.connection.url">jdbc:postgresql://10.0.0.7:5432/test_hibernate</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.password">1234</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property> -->
<!-- MYSQL -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/srh</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="testpackage/Felino.hbm.xml"/>
<mapping resource="testpackage/Mamifero.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Mamifero.hbm.xml
<?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="testpackage.Mamifero">
<id name="id" column="ID" type="long">
<generator class="increment"/>
</id>
<property name="lastName" column="LAST_NAME"/>
<property name="firstName" column="FIRST_NAME"/>
<union-subclass name="testpackage.Gato" table="GATO">
<property name="age" column="AGE"/>
</union-subclass>
<union-subclass name="testpackage.Cachorro" table="CACHORRO">
<property name="nome" column="NOME"/>
</union-subclass>
</class>
</hibernate-mapping>
Felino.hbm.xml
<?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="testpackage.Felino">
<id name="id" column="ID" type="long">
<generator class="increment"/>
</id>
<property name="raca" column="RACA"/>
<property name="familia" column="FAMILIA"/>
<union-subclass name="testpackage.Gato" table="GATO">
<property name="age" column="AGE"/>
</union-subclass>
</class>
</hibernate-mapping>
No cfg onde tem:
<mapping resource="testpackage/Felino.hbm.xml"/>
<mapping resource="testpackage/Mamifero.hbm.xml"/>
se eu deixar os dois descomentado da o seguinte erro qdo tem criar a Session Factory
org.hibernate.MappingException: Error reading resource: testpackage/Mamifero.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:444)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1369)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1341)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1323)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1290)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1252)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:151)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:128)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:50)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:166)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:915)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:866)
at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:785)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2773)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2432)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
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.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:704)
at org.eclipse.core.launcher.Main.main(Main.java:688)
Caused by: org.hibernate.MappingException: [b]duplicate import: testpackage.Gato[/b]
at org.hibernate.cfg.Mappings.addImport(Mappings.java:99)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:157)
at org.hibernate.cfg.HbmBinder.bindUnionSubclass(HbmBinder.java:309)
at org.hibernate.cfg.HbmBinder.handleUnionSubclass(HbmBinder.java:1535)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1472)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:579)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:1787)
at org.hibernate.cfg.Configuration.add(Configuration.java:355)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:392)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:441)
... 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 [/b]
valew pela a atencao, pensei q meu topico ia morfar aqui :lol:
espero q tenha entendido minha duvida :oops: