-->
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.  [ 11 posts ] 
Author Message
 Post subject: Inheritance and HQL Query problem
PostPosted: Tue Apr 27, 2004 8:18 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Hi All,

Here are my datas :

The Mapping file :

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
   <class name="majpps.beans.Environnement" table="environnement" lazy="false">
        <cache usage="read-only"/>

        <id name="idEnv" column="IDENV" unsaved-value="any">
            <generator class="sequence">
                <param name="seq_environnement">seq_environnement</param>
            </generator>
        </id>

        <discriminator column="TYPE_ENVIR" type="string"/>

        <property name="nom">
         <column name="NOM" sql-type="VARCHAR2(50)" not-null="true"/>
      </property>

      <subclass name="majpps.beans.EnvironnementPoste" lazy="false" discriminator-value="POSTE"
          dynamic-update="true" dynamic-insert="true">
               <property name="version">
                  <column name="VERSION" sql-type="VARCHAR2(50)" not-null="true"/>
               </property>
               <property name="code">
                  <column name="CODE" sql-type="VARCHAR2(50)" not-null="true"/>
               </property>
      </subclass>

      <subclass name="majpps.beans.SolutionLecteur" lazy="false" discriminator-value="LECTEUR"
         dynamic-update="true" dynamic-insert="true"/>

   </class>

</hibernate-mapping>


The Classes :
Environnement is a JavaBean with 'nom' attribute and accessers.
EnvironnementPoste is a JavaBean with attributes 'version', 'code' and accessers, it extends Environnement.
SolutionPoste is a JavaBean with no attribute, it extends Environnement.

The DataBase (Oracle) :
A Table ENVIRONNEMENT with columns IDENV, TYPE_ENVIR, NOM, VERSION, CODE.

The HQL Query :
from Environnement

The result :
I have a query with only IDENV, CODE and VERSION columns inside... not NOM...

Why please ??

Thank you !! =)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 27, 2004 9:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what sql is generated?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 27, 2004 9:25 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Wouah !! Watching my logs, searching for the SQL generated (is it possible in Hibernator?) I've seen this :

Code:
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for version in class majpps.beans.SolutionLecteur
   at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206)
   at net.sf.hibernator.QueryResults.getElement(QueryResults.java:64)
   at net.sf.hibernator.views.TableAdapter.setData(TableAdapter.java:41)
   at net.sf.hibernator.views.TableAdapter.createFromQuery(TableAdapter.java:26)
   at net.sf.hibernator.views.ResultsView.loadTable(ResultsView.java:74)
   at net.sf.hibernator.views.ResultsView$2.run(ResultsView.java:57)
   at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:127)
   at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:24)
   at org.eclipse.swt.widgets.Display.syncExec(Display.java:2337)
   at net.sf.hibernator.views.ResultsView.loadQuery(ResultsView.java:55)
   at net.sf.hibernator.views.QueryView.execute(QueryView.java:171)
   at net.sf.hibernator.views.QueryView.access$0(QueryView.java:154)
   at net.sf.hibernator.views.QueryView$1.handleEvent(QueryView.java:66)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402)
   at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
   at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
   at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
   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:324)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:291)
   at org.eclipse.core.launcher.Main.run(Main.java:747)
   at org.eclipse.core.launcher.Main.main(Main.java:583)

net.sf.hibernate.PropertyNotFoundException: Could not find a getter for code in class majpps.beans.SolutionLecteur
   at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206)
   at net.sf.hibernator.QueryResults.getElement(QueryResults.java:64)
   at net.sf.hibernator.views.TableAdapter.setData(TableAdapter.java:41)
   at net.sf.hibernator.views.TableAdapter.createFromQuery(TableAdapter.java:26)
   at net.sf.hibernator.views.ResultsView.loadTable(ResultsView.java:74)
   at net.sf.hibernator.views.ResultsView$2.run(ResultsView.java:57)
   at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:127)
   at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:24)
   at org.eclipse.swt.widgets.Display.syncExec(Display.java:2337)
   at net.sf.hibernator.views.ResultsView.loadQuery(ResultsView.java:55)
   at net.sf.hibernator.views.QueryView.execute(QueryView.java:171)
   at net.sf.hibernator.views.QueryView.access$0(QueryView.java:154)
   at net.sf.hibernator.views.QueryView$1.handleEvent(QueryView.java:66)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402)
   at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
   at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
   at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
   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:324)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:291)
   at org.eclipse.core.launcher.Main.run(Main.java:747)
   at org.eclipse.core.launcher.Main.main(Main.java:583)

net.sf.hibernate.PropertyNotFoundException: Could not find a getter for version in class majpps.beans.SolutionLecteur
   at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206)
   at net.sf.hibernator.QueryResults.getElement(QueryResults.java:64)
   at net.sf.hibernator.views.TableAdapter.setData(TableAdapter.java:41)
   at net.sf.hibernator.views.TableAdapter.createFromQuery(TableAdapter.java:26)
   at net.sf.hibernator.views.ResultsView.loadTable(ResultsView.java:74)
   at net.sf.hibernator.views.ResultsView$2.run(ResultsView.java:57)
   at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:127)
   at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:24)
   at org.eclipse.swt.widgets.Display.syncExec(Display.java:2337)
   at net.sf.hibernator.views.ResultsView.loadQuery(ResultsView.java:55)
   at net.sf.hibernator.views.QueryView.execute(QueryView.java:171)
   at net.sf.hibernator.views.QueryView.access$0(QueryView.java:154)
   at net.sf.hibernator.views.QueryView$1.handleEvent(QueryView.java:66)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402)
   at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
   at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
   at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
   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:324)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:291)
   at org.eclipse.core.launcher.Main.run(Main.java:747)
   at org.eclipse.core.launcher.Main.main(Main.java:583)

net.sf.hibernate.PropertyNotFoundException: Could not find a getter for code in class majpps.beans.SolutionLecteur
   at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206)
   at net.sf.hibernator.QueryResults.getElement(QueryResults.java:64)
   at net.sf.hibernator.views.TableAdapter.setData(TableAdapter.java:41)
   at net.sf.hibernator.views.TableAdapter.createFromQuery(TableAdapter.java:26)
   at net.sf.hibernator.views.ResultsView.loadTable(ResultsView.java:74)
   at net.sf.hibernator.views.ResultsView$2.run(ResultsView.java:57)
   at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:127)
   at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:24)
   at org.eclipse.swt.widgets.Display.syncExec(Display.java:2337)
   at net.sf.hibernator.views.ResultsView.loadQuery(ResultsView.java:55)
   at net.sf.hibernator.views.QueryView.execute(QueryView.java:171)
   at net.sf.hibernator.views.QueryView.access$0(QueryView.java:154)
   at net.sf.hibernator.views.QueryView$1.handleEvent(QueryView.java:66)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2022)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1729)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402)
   at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
   at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
   at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
   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:324)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:291)
   at org.eclipse.core.launcher.Main.run(Main.java:747)
   at org.eclipse.core.launcher.Main.main(Main.java:583)


Why should SolutionLecteur need accessers for those attributes since it don't have it...???!! :O

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 27, 2004 9:34 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
seems the problem is not the hql...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 27, 2004 9:49 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
.....and it could be........ ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 27, 2004 10:48 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
Teuf wrote:
.....and it could be........ ?


Does your mapped java class have a getVersion method? ;)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 27, 2004 10:51 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
As you can see, SolutionLecteur as no attribute... so what the hell hibernate is asking me ??? Devs ?? Please ?? :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 29, 2004 10:55 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Hey People !! Please ??!!! Could you help me ?? =(

I really don't understand ! =(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 29, 2004 11:16 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Hey guys ! I've find the solution for the first problem ! My mapping file is as the following one now and get all the columns...

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
   <class name="majpps.beans.Environnement" table="environnement" lazy="false">
        <cache usage="read-write"/>

        <id name="idEnv" column="IDENV" unsaved-value="null">
            <generator class="sequence">
                <param name="seq_environnement">seq_environnement</param>
            </generator>
        </id>

        <discriminator column="TYPE_ENVIR" type="string"/>

        <property name="Nom">
         <column name="NOM" sql-type="VARCHAR2(50)" not-null="true"/>
      </property>

      <subclass name="majpps.beans.EnvironnementPoste" lazy="false" discriminator-value="POSTE">
         <property name="Nom" insert="false" update="false">
            <column name="NOM" sql-type="VARCHAR2(50)" not-null="true"/>
         </property>
         <property name="version">
            <column name="VERSION" sql-type="VARCHAR2(50)" not-null="true"/>
         </property>
         <property name="code">
            <column name="CODE" sql-type="VARCHAR2(50)" not-null="true"/>
         </property>
      </subclass>

      <subclass name="majpps.beans.SolutionLecteur" lazy="false" discriminator-value="LECTEUR">
         <property name="Nom" insert="false" update="false">
            <column name="NOM" sql-type="VARCHAR2(50)" not-null="true"/>
         </property>
      </subclass>

   </class>

</hibernate-mapping>
<!-- parsed in 0ms -->


But always no solution for the exception generated !! Is This A bug from Hibernate ????


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 29, 2004 11:36 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
But always no solution for the exception generated !! Is This A bug from Hibernate ????

certainly not

show as asked at the begining, what sql is generated? show the new stacktrace


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 29, 2004 12:02 pm 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Huuuuhh i'm very sorry :O... In fact, it seems that only Hibernator is having the problem since the exception is not thrown via Hibernate...

Sorry to all !! =)

Thanks Delprouve


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