-->
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.  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: exception during native sql query
PostPosted: Sat Oct 09, 2004 6:50 am 
Newbie

Joined: Mon Sep 20, 2004 11:09 am
Posts: 8
hi i get an exception when i try to execute a native sql query on a mapping class that contains a <joined-subclass> element.

Hibernate version: 2.1.6

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

<hibernate-mapping>
<class
name="musicfinder.persistence.hibernate.bean.Archivable"
table="Archivable"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="id"
type="long"
unsaved-value="0"
>
<generator class="native">
</generator>
</id>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Archivable.xml
containing the additional properties and place it in your merge dir.
-->

<joined-subclass
name="musicfinder.persistence.hibernate.bean.Media"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="archivable"
/>
<property
name="timestamp"
type="timestamp"
update="true"
insert="true"
access="property"
column="timestamp"
/>

</joined-subclass>

</class>

</hibernate-mapping>



Code:
query = "SELECT {Archivable.*} FROM Archivable Archivable";
logger.debug("findArchivable: query: " + query);
Session session = HibernateSession.acquireSession();
try {
Query q = session.createSQLQuery(query, "Archivable", Archivable.class);
List list = q.list();
return list;
} finally {
HibernateSession.releaseSession();
}


Full stack trace of any exception that occurs:
Code:
java.sql.SQLException: General error, message from server: "Unknown table 'Archivable_1_' in field list"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1538)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at musicfinder.persistence.hibernate.MediaDAOSessionBean.findArchivable(MediaDAOSessionBean.java:111)
at musicfinder.persistence.hibernate.MediaDAOSessionBean.main(MediaDAOSessionBean.java:376)


Name and version of the database you are using:
mysql 4.0.16

The generated SQL (show_sql=true):
Code:
Hibernate: SELECT Archivable.id as id0_, case when Archivable_1_.archivable is not null then 1 when Archivable.id is not null then 0 end as clazz_0_, Archivable_1_.timestamp as timestamp1_0_ FROM Archivable Archivable


Debug level Hibernate log excerpt:
Code:
INFO  2004-10-09 12:45:20,472 [cfg.Environment; main]: Hibernate 2.1.6
INFO  2004-10-09 12:45:20,474 [cfg.Environment; main]: hibernate.properties not found
INFO  2004-10-09 12:45:20,483 [cfg.Environment; main]: using CGLIB reflection optimizer
INFO  2004-10-09 12:45:20,495 [cfg.Configuration; main]: configuring from resource: /hibernate.cfg.xml
INFO  2004-10-09 12:45:20,496 [cfg.Configuration; main]: Configuration resource: /hibernate.cfg.xml
DEBUG 2004-10-09 12:45:20,709 [util.DTDEntityResolver; main]: trying to locate http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd in classpath under net/sf/hibernate/
DEBUG 2004-10-09 12:45:20,716 [util.DTDEntityResolver; main]: found http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd in classpath
DEBUG 2004-10-09 12:45:20,843 [cfg.Configuration; main]: connection.driver_class=org.gjt.mm.mysql.Driver
DEBUG 2004-10-09 12:45:20,844 [cfg.Configuration; main]: connection.url=jdbc:mysql://localhost:3306/jboss
DEBUG 2004-10-09 12:45:20,844 [cfg.Configuration; main]: connection.username=jboss
DEBUG 2004-10-09 12:45:20,845 [cfg.Configuration; main]: connection.password=jboss
DEBUG 2004-10-09 12:45:20,845 [cfg.Configuration; main]: dialect=net.sf.hibernate.dialect.MySQLDialect
DEBUG 2004-10-09 12:45:20,845 [cfg.Configuration; main]: show_sql=true
DEBUG 2004-10-09 12:45:20,845 [cfg.Configuration; main]: use_outer_join=true
DEBUG 2004-10-09 12:45:20,849 [cfg.Configuration; main]: null<-org.dom4j.tree.DefaultAttribute@b1b4c3 [Attribute: name resource value "musicfinder/persistence/hibernate/bean/Archivable.hbm.xml"]
INFO  2004-10-09 12:45:20,850 [cfg.Configuration; main]: Mapping resource: musicfinder/persistence/hibernate/bean/Archivable.hbm.xml
DEBUG 2004-10-09 12:45:20,854 [util.DTDEntityResolver; main]: trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
DEBUG 2004-10-09 12:45:20,861 [util.DTDEntityResolver; main]: found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
INFO  2004-10-09 12:45:21,140 [cfg.Binder; main]: Mapping class: musicfinder.persistence.hibernate.bean.Archivable -> Archivable
DEBUG 2004-10-09 12:45:21,350 [cfg.Binder; main]: Mapped property: id -> id, type: long
INFO  2004-10-09 12:45:21,535 [cfg.Binder; main]: Mapping joined-subclass: musicfinder.persistence.hibernate.bean.Media -> Media
DEBUG 2004-10-09 12:45:21,540 [cfg.Binder; main]: Mapped property: timestamp -> timestamp, type: timestamp
DEBUG 2004-10-09 12:45:21,540 [cfg.Configuration; main]: null<-org.dom4j.tree.DefaultAttribute@1c282a1 [Attribute: name resource value "musicfinder/persistence/hibernate/bean/AttributeType.hbm.xml"]
INFO  2004-10-09 12:45:21,541 [cfg.Configuration; main]: Mapping resource: musicfinder/persistence/hibernate/bean/AttributeType.hbm.xml
DEBUG 2004-10-09 12:45:21,544 [util.DTDEntityResolver; main]: trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
DEBUG 2004-10-09 12:45:21,546 [util.DTDEntityResolver; main]: found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
INFO  2004-10-09 12:45:21,617 [cfg.Binder; main]: Mapping class: musicfinder.persistence.hibernate.bean.AttributeType -> AttributeType
DEBUG 2004-10-09 12:45:21,618 [cfg.Binder; main]: Mapped property: id -> id, type: long
DEBUG 2004-10-09 12:45:21,619 [cfg.Binder; main]: Mapped property: name -> name, type: string
INFO  2004-10-09 12:45:21,622 [cfg.Binder; main]: Mapping collection: musicfinder.persistence.hibernate.bean.AttributeType.attributeViews -> AttributeType_AttributeView
DEBUG 2004-10-09 12:45:21,642 [cfg.Binder; main]: Mapped property: attributeViews, type: java.util.Set
INFO  2004-10-09 12:45:21,643 [cfg.Binder; main]: Mapping collection: musicfinder.persistence.hibernate.bean.AttributeType.defaultValues -> DefaultValue
DEBUG 2004-10-09 12:45:21,643 [cfg.Binder; main]: Mapped property: defaultValues, type: java.util.Set
DEBUG 2004-10-09 12:45:21,644 [cfg.Binder; main]: Mapped property: inputFieldType -> inputFieldType, type: string
DEBUG 2004-10-09 12:45:21,644 [cfg.Configuration; main]: null<-org.dom4j.tree.DefaultAttribute@12a0f6c [Attribute: name resource value "musicfinder/persistence/hibernate/bean/AttributeView.hbm.xml"]
INFO  2004-10-09 12:45:21,645 [cfg.Configuration; main]: Mapping resource: musicfinder/persistence/hibernate/bean/AttributeView.hbm.xml
DEBUG 2004-10-09 12:45:21,653 [util.DTDEntityResolver; main]: trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
DEBUG 2004-10-09 12:45:21,655 [util.DTDEntityResolver; main]: found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
INFO  2004-10-09 12:45:21,710 [cfg.Binder; main]: Mapping class: musicfinder.persistence.hibernate.bean.AttributeView -> AttributeView
DEBUG 2004-10-09 12:45:21,711 [cfg.Binder; main]: Mapped property: id -> id, type: long
DEBUG 2004-10-09 12:45:21,712 [cfg.Binder; main]: Mapped property: name -> value, type: string
INFO  2004-10-09 12:45:21,713 [cfg.Binder; main]: Mapping collection: musicfinder.persistence.hibernate.bean.AttributeView.attributeTypes -> AttributeType_AttributeView
DEBUG 2004-10-09 12:45:21,723 [cfg.Binder; main]: Mapped property: attributeTypes, type: java.util.List
DEBUG 2004-10-09 12:45:21,724 [cfg.Configuration; main]: null<-org.dom4j.tree.DefaultAttribute@13ad085 [Attribute: name resource value "musicfinder/persistence/hibernate/bean/ArchivableObject.hbm.xml"]
INFO  2004-10-09 12:45:21,724 [cfg.Configuration; main]: Mapping resource: musicfinder/persistence/hibernate/bean/ArchivableObject.hbm.xml
DEBUG 2004-10-09 12:45:21,727 [util.DTDEntityResolver; main]: trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
DEBUG 2004-10-09 12:45:21,729 [util.DTDEntityResolver; main]: found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
INFO  2004-10-09 12:45:21,796 [cfg.Binder; main]: Mapping class: musicfinder.persistence.hibernate.bean.ArchivableObject -> File
DEBUG 2004-10-09 12:45:21,798 [cfg.Binder; main]: Mapped property: id -> id, type: long
DEBUG 2004-10-09 12:45:21,799 [cfg.Binder; main]: Mapped property: mimeType -> mimeType, type: string
DEBUG 2004-10-09 12:45:21,800 [cfg.Binder; main]: Mapped property: hash -> hash, type: string
DEBUG 2004-10-09 12:45:21,800 [cfg.Binder; main]: Mapped property: URL -> url, type: string
INFO  2004-10-09 12:45:21,803 [cfg.Binder; main]: Mapping collection: musicfinder.persistence.hibernate.bean.ArchivableObject.attributes -> archivableObjectAttribute
DEBUG 2004-10-09 12:45:21,809 [cfg.Binder; main]: Mapped property: attributes, type: java.util.Map
INFO  2004-10-09 12:45:21,810 [cfg.Configuration; main]: Configured SessionFactory: null
DEBUG 2004-10-09 12:45:21,811 [cfg.Configuration; main]: properties: {hibernate.connection.password=jboss, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i386, java.vm.version=1.4.2_03-b02, hibernate.connection.username=jboss, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, use_outer_join=true, user.country=US, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2, java.runtime.version=1.4.2_03-b02, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/endorsed, os.arch=i386, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., os.name=Linux, sun.java2d.fontpath=, java.library.path=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i386/client:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i386:/home/tj/develop/java/j2sdk1.4.2_03/jre/../lib/i386:/home/tj/develop/bin/../java/IBMJava2-141/bin:/home/tj/develop/bin/../java/IBMJava2-141/jre/bin/classic:/home/tj/develop/bin/../java/IBMJava2-141/jre/bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.FileSystemPreferencesFactory, os.version=2.4.23-xfs, connection.password=jboss, user.home=/home/tj, user.timezone=Europe/Berlin, connection.username=jboss, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=ANSI_X3.4-1968, java.specification.version=1.4, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, show_sql=true, user.name=tj, java.class.path=/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2/bin:/home/tj/develop/java/jboss/client/log4j.jar:/home/tj/develop/java/jboss/client/concurrent.jar:/home/tj/develop/java/jboss/client/gnu-regexp.jar:/home/tj/develop/java/jboss/client/jacorb.jar:/home/tj/develop/java/jboss/client/jboss-client.jar:/home/tj/develop/java/jboss/client/jboss-common-client.jar:/home/tj/develop/java/jboss/client/jboss-iiop-client.jar:/home/tj/develop/java/jboss/client/jboss-j2ee.jar:/home/tj/develop/java/jboss/client/jboss-jaas.jar:/home/tj/develop/java/jboss/client/jboss-net-client.jar:/home/tj/develop/java/jboss/client/jboss-system-client.jar:/home/tj/develop/java/jboss/client/jbossall-client.jar:/home/tj/develop/java/jboss/client/jbossha-client.jar:/home/tj/develop/java/jboss/client/jbossjmx-ant.jar:/home/tj/develop/java/jboss/client/jbossmq-client.jar:/home/tj/develop/java/jboss/client/jbosssx-client.jar:/home/tj/develop/java/jboss/client/jcert.jar:/home/tj/develop/java/jboss/client/jmx-connector-client-factory.jar:/home/tj/develop/java/jboss/client/jmx-ejb-connector-client.jar:/home/tj/develop/java/jboss/client/jmx-invoker-adaptor-client.jar:/home/tj/develop/java/jboss/client/jmx-rmi-connector-client.jar:/home/tj/develop/java/jboss/client/jnet.jar:/home/tj/develop/java/jboss/client/jnp-client.jar:/home/tj/develop/java/jboss/client/jsse.jar:/home/tj/develop/java/jboss/server/default/lib/javax.servlet.jar:/home/tj/develop/java/struts/lib/struts.jar:/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2/lib/ejb/ejbutils-client.jar:/home/tj/develop/java/mysql-connector-java/mysql-connector-java-bin.jar:/home/tj/develop/java/eclipse/plugins/org.junit_3.8.1/junit.jar:/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2/lib/jid3lib-0.5.jar:/home/tj/develop/java/JMF-2.1.1e/lib/jmf.jar:/home/tj/develop/java/eclipse-2.1.2/workspace/mp3info/bin:/home/tj/develop/java/hibernate/hibernate2.jar:/home/tj/develop/java/hibernate/lib/odmg-3.0.jar:/home/tj/develop/java/hibernate/lib/ehcache-0.9.jar:/home/tj/develop/java/hibernate/lib/dom4j-1.4.jar:/home/tj/develop/java/hibernate/lib/cglib-full-2.0.2.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=/home/tj/develop/java/j2sdk1.4.2_03/jre, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost:3306/jboss, user.language=en, java.specification.vendor=Sun Microsystems Inc., hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_03, java.ext.dirs=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/ext, sun.boot.class.path=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/rt.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i18n.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/sunrsasign.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/jsse.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/jce.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/charsets.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/classes, java.vendor=Sun Microsystems Inc., connection.driver_class=org.gjt.mm.mysql.Driver, file.separator=/, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, hibernate.use_outer_join=true, connection.url=jdbc:mysql://localhost:3306/jboss, dialect=net.sf.hibernate.dialect.MySQLDialect, sun.cpu.isalist=}
INFO  2004-10-09 12:45:21,814 [cfg.Configuration; main]: processing one-to-many association mappings
DEBUG 2004-10-09 12:45:21,814 [cfg.Binder; main]: Second pass for collection: musicfinder.persistence.hibernate.bean.AttributeType.attributeViews
DEBUG 2004-10-09 12:45:21,825 [cfg.Binder; main]: Mapped collection key: attributeTypeID, element: attributeViewID, type: musicfinder.persistence.hibernate.bean.AttributeView
DEBUG 2004-10-09 12:45:21,826 [cfg.Binder; main]: Second pass for collection: musicfinder.persistence.hibernate.bean.AttributeType.defaultValues
DEBUG 2004-10-09 12:45:21,827 [cfg.Binder; main]: Mapped collection key: attributeTypeId, element: value, type: string
DEBUG 2004-10-09 12:45:21,827 [cfg.Binder; main]: Second pass for collection: musicfinder.persistence.hibernate.bean.AttributeView.attributeTypes
DEBUG 2004-10-09 12:45:21,829 [cfg.Binder; main]: Mapped collection key: attributeViewID, index: orderIndex, element: attributeTypeID, type: musicfinder.persistence.hibernate.bean.AttributeType
DEBUG 2004-10-09 12:45:21,829 [cfg.Binder; main]: Second pass for collection: musicfinder.persistence.hibernate.bean.ArchivableObject.attributes
DEBUG 2004-10-09 12:45:21,830 [cfg.Binder; main]: Mapped collection key: archivableObjectID, index: attributeName, element: a_value, type: string
INFO  2004-10-09 12:45:21,830 [cfg.Configuration; main]: processing one-to-one association property references
INFO  2004-10-09 12:45:21,831 [cfg.Configuration; main]: processing foreign key constraints
DEBUG 2004-10-09 12:45:21,832 [cfg.Configuration; main]: resolving reference to class: musicfinder.persistence.hibernate.bean.AttributeType
DEBUG 2004-10-09 12:45:21,832 [cfg.Configuration; main]: resolving reference to class: musicfinder.persistence.hibernate.bean.AttributeView
DEBUG 2004-10-09 12:45:21,833 [cfg.Configuration; main]: resolving reference to class: musicfinder.persistence.hibernate.bean.AttributeType
DEBUG 2004-10-09 12:45:21,833 [cfg.Configuration; main]: resolving reference to class: musicfinder.persistence.hibernate.bean.ArchivableObject
DEBUG 2004-10-09 12:45:21,833 [cfg.Configuration; main]: resolving reference to class: musicfinder.persistence.hibernate.bean.Archivable
INFO  2004-10-09 12:45:21,890 [dialect.Dialect; main]: Using dialect: net.sf.hibernate.dialect.MySQLDialect
INFO  2004-10-09 12:45:21,917 [cfg.SettingsFactory; main]: Maximim outer join fetch depth: 2
INFO  2004-10-09 12:45:21,918 [cfg.SettingsFactory; main]: Use outer join fetching: true
INFO  2004-10-09 12:45:21,933 [connection.DriverManagerConnectionProvider; main]: Using Hibernate built-in connection pool (not for production use!)
INFO  2004-10-09 12:45:21,933 [connection.DriverManagerConnectionProvider; main]: Hibernate connection pool size: 20
INFO  2004-10-09 12:45:21,953 [connection.DriverManagerConnectionProvider; main]: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/jboss
INFO  2004-10-09 12:45:21,953 [connection.DriverManagerConnectionProvider; main]: connection properties: {user=jboss, password=jboss}
INFO  2004-10-09 12:45:21,997 [transaction.TransactionManagerLookupFactory; main]: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
DEBUG 2004-10-09 12:45:21,998 [connection.DriverManagerConnectionProvider; main]: total checked-out connections: 0
DEBUG 2004-10-09 12:45:21,998 [connection.DriverManagerConnectionProvider; main]: opening new JDBC connection
DEBUG 2004-10-09 12:45:22,422 [connection.DriverManagerConnectionProvider; main]: created connection to: jdbc:mysql://localhost:3306/jboss, Isolation Level: 4
DEBUG 2004-10-09 12:45:22,425 [connection.DriverManagerConnectionProvider; main]: returning connection to pool, pool size: 1
INFO  2004-10-09 12:45:22,426 [cfg.SettingsFactory; main]: Use scrollable result sets: true
INFO  2004-10-09 12:45:22,426 [cfg.SettingsFactory; main]: Use JDBC3 getGeneratedKeys(): true
INFO  2004-10-09 12:45:22,426 [cfg.SettingsFactory; main]: Optimize cache for minimal puts: false
INFO  2004-10-09 12:45:22,427 [cfg.SettingsFactory; main]: echoing all SQL to stdout
INFO  2004-10-09 12:45:22,427 [cfg.SettingsFactory; main]: Query language substitutions: {}
INFO  2004-10-09 12:45:22,428 [cfg.SettingsFactory; main]: cache provider: net.sf.hibernate.cache.EhCacheProvider
INFO  2004-10-09 12:45:22,434 [cfg.Configuration; main]: instantiating and configuring caches
INFO  2004-10-09 12:45:23,007 [impl.SessionFactoryImpl; main]: building session factory
DEBUG 2004-10-09 12:45:23,008 [impl.SessionFactoryImpl; main]: instantiating session factory with properties: {hibernate.connection.password=jboss, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i386, java.vm.version=1.4.2_03-b02, hibernate.connection.username=jboss, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, use_outer_join=true, user.country=US, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2, java.runtime.version=1.4.2_03-b02, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/endorsed, os.arch=i386, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., os.name=Linux, sun.java2d.fontpath=, java.library.path=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i386/client:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i386:/home/tj/develop/java/j2sdk1.4.2_03/jre/../lib/i386:/home/tj/develop/bin/../java/IBMJava2-141/bin:/home/tj/develop/bin/../java/IBMJava2-141/jre/bin/classic:/home/tj/develop/bin/../java/IBMJava2-141/jre/bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.FileSystemPreferencesFactory, os.version=2.4.23-xfs, connection.password=jboss, user.home=/home/tj, user.timezone=Europe/Berlin, connection.username=jboss, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=ANSI_X3.4-1968, java.specification.version=1.4, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, show_sql=true, user.name=tj, java.class.path=/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2/bin:/home/tj/develop/java/jboss/client/log4j.jar:/home/tj/develop/java/jboss/client/concurrent.jar:/home/tj/develop/java/jboss/client/gnu-regexp.jar:/home/tj/develop/java/jboss/client/jacorb.jar:/home/tj/develop/java/jboss/client/jboss-client.jar:/home/tj/develop/java/jboss/client/jboss-common-client.jar:/home/tj/develop/java/jboss/client/jboss-iiop-client.jar:/home/tj/develop/java/jboss/client/jboss-j2ee.jar:/home/tj/develop/java/jboss/client/jboss-jaas.jar:/home/tj/develop/java/jboss/client/jboss-net-client.jar:/home/tj/develop/java/jboss/client/jboss-system-client.jar:/home/tj/develop/java/jboss/client/jbossall-client.jar:/home/tj/develop/java/jboss/client/jbossha-client.jar:/home/tj/develop/java/jboss/client/jbossjmx-ant.jar:/home/tj/develop/java/jboss/client/jbossmq-client.jar:/home/tj/develop/java/jboss/client/jbosssx-client.jar:/home/tj/develop/java/jboss/client/jcert.jar:/home/tj/develop/java/jboss/client/jmx-connector-client-factory.jar:/home/tj/develop/java/jboss/client/jmx-ejb-connector-client.jar:/home/tj/develop/java/jboss/client/jmx-invoker-adaptor-client.jar:/home/tj/develop/java/jboss/client/jmx-rmi-connector-client.jar:/home/tj/develop/java/jboss/client/jnet.jar:/home/tj/develop/java/jboss/client/jnp-client.jar:/home/tj/develop/java/jboss/client/jsse.jar:/home/tj/develop/java/jboss/server/default/lib/javax.servlet.jar:/home/tj/develop/java/struts/lib/struts.jar:/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2/lib/ejb/ejbutils-client.jar:/home/tj/develop/java/mysql-connector-java/mysql-connector-java-bin.jar:/home/tj/develop/java/eclipse/plugins/org.junit_3.8.1/junit.jar:/home/tj/develop/java/eclipse-2.1.2/workspace/Musicfinder-xdoclet-2/lib/jid3lib-0.5.jar:/home/tj/develop/java/JMF-2.1.1e/lib/jmf.jar:/home/tj/develop/java/eclipse-2.1.2/workspace/mp3info/bin:/home/tj/develop/java/hibernate/hibernate2.jar:/home/tj/develop/java/hibernate/lib/odmg-3.0.jar:/home/tj/develop/java/hibernate/lib/ehcache-0.9.jar:/home/tj/develop/java/hibernate/lib/dom4j-1.4.jar:/home/tj/develop/java/hibernate/lib/cglib-full-2.0.2.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=/home/tj/develop/java/j2sdk1.4.2_03/jre, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost:3306/jboss, user.language=en, java.specification.vendor=Sun Microsystems Inc., hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_03, java.ext.dirs=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/ext, sun.boot.class.path=/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/rt.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/i18n.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/sunrsasign.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/jsse.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/jce.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/lib/charsets.jar:/home/tj/develop/java/j2sdk1.4.2_03/jre/classes, java.vendor=Sun Microsystems Inc., connection.driver_class=org.gjt.mm.mysql.Driver, file.separator=/, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, hibernate.use_outer_join=true, connection.url=jdbc:mysql://localhost:3306/jboss, dialect=net.sf.hibernate.dialect.MySQLDialect, sun.cpu.isalist=}
DEBUG 2004-10-09 12:45:23,852 [impl.SessionFactoryObjectFactory; main]: initializing class SessionFactoryObjectFactory
DEBUG 2004-10-09 12:45:23,864 [impl.SessionFactoryObjectFactory; main]: registered: ff808081ff7d4aeb00ff7d4af1070000 (unnamed)
INFO  2004-10-09 12:45:23,865 [impl.SessionFactoryObjectFactory; main]: Not binding factory to JNDI, no JNDI name configured
DEBUG 2004-10-09 12:45:23,865 [impl.SessionFactoryImpl; main]: instantiated session factory
DEBUG 2004-10-09 12:45:23,865 [util.HibernateSession; main]: Creating new session
DEBUG 2004-10-09 12:45:24,024 [impl.SessionImpl; main]: opened session
DEBUG 2004-10-09 12:45:24,048 [domain.BaseRemoteSessionBean; main]: query parameter 0 : AttributeType.name: Title - Value: track%
DEBUG 2004-10-09 12:45:24,056 [impl.SessionImpl; main]: SQL query: SELECT {Archivable.*} FROM Archivable Archivable
DEBUG 2004-10-09 12:45:24,086 [impl.SessionImpl; main]: flushing session
DEBUG 2004-10-09 12:45:24,087 [impl.SessionImpl; main]: Flushing entities and processing referenced collections
DEBUG 2004-10-09 12:45:24,087 [impl.SessionImpl; main]: Processing unreferenced collections
DEBUG 2004-10-09 12:45:24,088 [impl.SessionImpl; main]: Scheduling collection removes/(re)creates/updates
DEBUG 2004-10-09 12:45:24,088 [impl.SessionImpl; main]: Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
DEBUG 2004-10-09 12:45:24,088 [impl.SessionImpl; main]: Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG 2004-10-09 12:45:24,093 [impl.SessionImpl; main]: Dont need to execute flush
DEBUG 2004-10-09 12:45:24,094 [impl.BatcherImpl; main]: about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG 2004-10-09 12:45:24,094 [connection.DriverManagerConnectionProvider; main]: total checked-out connections: 0
DEBUG 2004-10-09 12:45:24,094 [connection.DriverManagerConnectionProvider; main]: using pooled JDBC connection, pool size: 0
DEBUG 2004-10-09 12:45:24,095 [hibernate.SQL; main]: SELECT Archivable.id as id0_, case when Archivable_1_.archivable is not null then 1 when Archivable.id is not null then 0 end as clazz_0_, Archivable_1_.timestamp as timestamp1_0_ FROM Archivable Archivable
Hibernate: SELECT Archivable.id as id0_, case when Archivable_1_.archivable is not null then 1 when Archivable.id is not null then 0 end as clazz_0_, Archivable_1_.timestamp as timestamp1_0_ FROM Archivable Archivable
DEBUG 2004-10-09 12:45:24,096 [impl.BatcherImpl; main]: preparing statement
DEBUG 2004-10-09 12:45:24,136 [util.JDBCExceptionReporter; main]: SQL Exception
java.sql.SQLException: General error,  message from server: "Unknown table 'Archivable_1_' in field list"
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1538)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
   at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.findArchivable(MediaDAOSessionBean.java:111)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.main(MediaDAOSessionBean.java:376)
WARN  2004-10-09 12:45:24,138 [util.JDBCExceptionReporter; main]: SQL Error: 1109, SQLState: S1000
ERROR 2004-10-09 12:45:24,139 [util.JDBCExceptionReporter; main]: General error,  message from server: "Unknown table 'Archivable_1_' in field list"
DEBUG 2004-10-09 12:45:24,139 [impl.BatcherImpl; main]: done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG 2004-10-09 12:45:24,139 [impl.BatcherImpl; main]: closing statement
DEBUG 2004-10-09 12:45:24,147 [util.JDBCExceptionReporter; main]: SQL Exception
java.sql.SQLException: General error,  message from server: "Unknown table 'Archivable_1_' in field list"
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1538)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
   at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.findArchivable(MediaDAOSessionBean.java:111)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.main(MediaDAOSessionBean.java:376)
WARN  2004-10-09 12:45:24,149 [util.JDBCExceptionReporter; main]: SQL Error: 1109, SQLState: S1000
ERROR 2004-10-09 12:45:24,149 [util.JDBCExceptionReporter; main]: General error,  message from server: "Unknown table 'Archivable_1_' in field list"
ERROR 2004-10-09 12:45:24,149 [util.JDBCExceptionReporter; main]: SQLException occurred
java.sql.SQLException: General error,  message from server: "Unknown table 'Archivable_1_' in field list"
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1538)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
   at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.findArchivable(MediaDAOSessionBean.java:111)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.main(MediaDAOSessionBean.java:376)
DEBUG 2004-10-09 12:45:24,153 [util.HibernateSession; main]: Releasing a session
DEBUG 2004-10-09 12:45:24,154 [util.HibernateSession; main]: Closing the released session
DEBUG 2004-10-09 12:45:24,154 [impl.SessionImpl; main]: closing session
DEBUG 2004-10-09 12:45:24,154 [impl.SessionImpl; main]: disconnecting session
DEBUG 2004-10-09 12:45:24,155 [connection.DriverManagerConnectionProvider; main]: returning connection to pool, pool size: 1
DEBUG 2004-10-09 12:45:24,155 [impl.SessionImpl; main]: transaction completion
musicfinder.persistence.PersistenceException: Could not retrieve Archivable
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.findArchivable(MediaDAOSessionBean.java:115)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.main(MediaDAOSessionBean.java:376)
Caused by: net.sf.hibernate.JDBCException: SQLException occurred
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3809)
   at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
   at musicfinder.persistence.hibernate.MediaDAOSessionBean.findArchivable(MediaDAOSessionBean.java:111)
   ... 1 more
Caused by: java.sql.SQLException: General error,  message from server: "Unknown table 'Archivable_1_' in field list"
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1538)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
   ... 3 more


when i do not have a joined-subclass element in the mapping document, everthing goes fine!
is there anything wrong with my mapping or my query?


Top
 Profile  
 
 Post subject: Any solution found?
PostPosted: Thu Oct 14, 2004 12:11 pm 
Newbie

Joined: Thu Oct 14, 2004 11:58 am
Posts: 3
I have the exact same problem. Has anyone found a solution for this? If so, a quick response would be greatly appreciated!


Top
 Profile  
 
 Post subject: A solution?
PostPosted: Thu Oct 14, 2004 12:16 pm 
Newbie

Joined: Thu Oct 14, 2004 11:58 am
Posts: 3
If anyone has a solution my email is gregb@saepio.com.


Top
 Profile  
 
 Post subject: Here is the fix.
PostPosted: Thu Oct 14, 2004 8:10 pm 
Newbie

Joined: Thu Oct 14, 2004 11:58 am
Posts: 3
My Saepio team figured out our problem, which was identical to this one.

PROBLEM IN A NUTSHELL:

The problem is that native SQL is being used instead of HQL.

A FEW DETAILS:

When the table of the base class is referenced in the above SQL statement, the {Archivable.*} token is replaced by all of the fields in the base class's table ***AND*** all the fields in the subclass's table. During this token expansion operation, Hibernate creates an alias name for the subclass's table and there is, apparently, no way the specify in the SQL what that alias name will be. That makes it impossible (I think) to declare the inner join in the from clause or the where clause.

THE FIX:

Instead of using the session.createSQLQuery(...) method the session.find(...) method should be used and the SQL should be translated into HQL.

For this example replace:

query = "SELECT {Archivable.*} FROM Archivable Archivable";
session.createSQLQuery(query, "Archivable", Archivable.class);

with:

session.find("FROM Archivable");

where "FROM Archivable" refers to the object not the table.


Top
 Profile  
 
 Post subject: need of native sql
PostPosted: Sun Oct 24, 2004 7:54 am 
Newbie

Joined: Mon Sep 20, 2004 11:09 am
Posts: 8
but i need native sql since my query is in fact quite a bit more complicated -
i want to join on an index column of a map - hql can not do that, can it?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 8:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
unfortunately createSQLQuery does not support the .* support when you have joined-subclass. You need to explicitly list the properties in the select clause.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 12:12 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
I am getting the same error when using a joined subclass and a native query.
I specified the properties according to the documentation.

My query looks like:
Code:
session.createSQLQuery(
"SELECT c.id as {customer.id},"+
   "c.companyid as {customer.company}," +
   "c.parentid as {customer.parent}," +
   "c.categoryid as {customer.category}," +
   "c.TIME_OF_CREATION as {customer.timeOfCreation}," +
   "c.TIME_OF_LAST_UPDATE as {customer.timeOfLastUpdate}," +
   "c.comments as {customer.comments}," +
   "c.debid as {customer.debid}," +
   "c.addressid as {customer.address}," +
   "c.defaultsortorderid as {customer.defaultSortOrder}," +
   "c.defaultUnitid as {customer.defaultUnit}" +
" FROM CUSTOMERS c","customer",nl.dennie.vikie.model.Customer.class).list();


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

<hibernate-mapping>
   <class name="nl.dennie.vikie.model.Customer" table="CUSTOMERS">

      <meta attribute="implements">BBO</meta>
      <meta attribute="class-code">

<![CDATA[
   PropertyChangeSupport changes = new PropertyChangeSupport(this);
]]>

      </meta>

      <meta attribute="extra-import">java.beans.PropertyChangeSupport</meta>
      <meta attribute="extra-import">java.beans.PropertyChangeListener</meta>


      <id name="id" type="int" column="ID">
         <meta attribute="beans-property-type">bound</meta>
         <meta attribute="use-in-tostring">true</meta>
         <generator class="identity"/>
      </id>

      <!-- The company this customer belongs to. N..1 Relation -->
      <many-to-one name="company" class="nl.dennie.vikie.model.Company">
         <meta attribute="beans-property-type">bound</meta>
         <meta attribute="use-in-tostring">true</meta>
         <column name="COMPANYID"/>
      </many-to-one>

      <!--  The Customer can have a parent value. If this value is active then -->
      <!--  the customer belongs to this customer. -->
      <many-to-one name="parent" class="nl.dennie.vikie.model.Customer">
         <meta attribute="beans-property-type">bound</meta>
         <meta attribute="use-in-tostring">true</meta>
         <column name="PARENTID"/>
      </many-to-one>

      <!-- The customer belongs to a category. We can group customers on this -->
      <!-- attribute. -->
      <many-to-one name="category" class="nl.dennie.vikie.model.CustomerCategory">
         <meta attribute="beans-property-type">bound</meta>
         <meta attribute="use-in-tostring">true</meta>
         <column name="CATEGORYID"/>
      </many-to-one>

      <property name="timeOfLastUpdate" type="calendar">
         <column name="TIME_OF_LAST_UPDATE"/>
      </property>

      <property name="timeOfCreation" type="calendar">
         <column name="TIME_OF_CREATION"/>
      </property>

      <property name="comments" type="text">
         <column name="COMMENTS"/>
      </property>

      <property name="debid" type="int">
         <column name="DEBID"/>
      </property>

      <many-to-one name="address"
            class="nl.dennie.vikie.model.Address"
            column="ADDRESSID"
            cascade="all"/>

      <!-- Collection with type of orders this customer can send packages with -->
      <list name="sortOrders" table="CUSTOMERSORTORDERS" lazy="true" >
         <key column="CUSTOMERID"/>
         <index column="LISTINDEX"/>
         <many-to-many column="SORTORDERID" class="nl.dennie.vikie.model.SortOrder"/>
      </list>

      <many-to-one name="defaultSortOrder" class="nl.dennie.vikie.model.SortOrder">
         <column name="DEFAULTSORTORDERID"/>
      </many-to-one>

      <list name="units" table="CUSTOMERUNITS" lazy="true">
         <key column="CUSTOMERID"/>
         <index column="LISTINDEX"/>
         <many-to-many class="nl.dennie.vikie.model.Unit">
            <column name="UNITID"/>
         </many-to-many>
      </list>

      <many-to-one name="defaultUnit" class="nl.dennie.vikie.model.Unit">
         <column name="DEFAULTUNITID"/>
      </many-to-one>

      <set name="ranges" table="RANGES" order-by="TIME_OF_CREATION desc"
         where="AVAILABLE > 0" lazy="true">
         <key column="CUSTOMERID"/>
         <one-to-many class="nl.dennie.vikie.model.Range"/>
      </set>

      <!-- Collection of conditions this customer has. -->
      <set name="conditions" table="CUSTOMERCONDITIONS" lazy="true" >
         <key column="CUSTOMERID"/>
         <many-to-many class="nl.dennie.vikie.model.Condition">
            <column name="CONDITIONID"/>
            </many-to-many>
      </set>

      <set name="users" table="users" lazy="true" >
         <key column="customerid"/>
         <one-to-many class="nl.dennie.vikie.model.User"/>
      </set>

      <map name="variables" table="CUSTOMERVARIABLES" cascade="all" lazy="true" order-by="TIME_OF_CREATION" >
         <key column="ID"/>
         <index column="NAME" type="string" length="20" />
         <composite-element class="nl.dennie.vikie.model.CustomerVariable">
            <property name="timeOfCreation" column="TIME_OF_CREATION" type="calendar"/>
            <property name="value" column="VALUE" type="string"/>
         </composite-element>
      </map>

      <joined-subclass
         name="nl.dennie.vikie.model.Company" table="COMPANIES" >
         <meta attribute="class-code">
<![CDATA[
   public void addEmailAccount(EmailAccount account){
      if(emailAccounts == null){
         emailAccounts = new java.util.HashSet();
      }
      emailAccounts.add(account);
   }
]]>
         </meta>
         <key column="ID"/>
         <set name="emailAccounts" table="EMAILACCOUNTS"
            lazy="true">
            <key column="COMPANYID"/>
            <one-to-many class="nl.dennie.vikie.model.EmailAccount"/>
         </set>

      </joined-subclass>
   </class>
</hibernate-mapping>


And the error generated by Hibernate is:
Code:
2726160 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - opened session
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - SQL query: SELECT c.id as {customer.id},c.companyid as {customer.company},c.parentid as {customer.parent},c.categoryid as {customer.category},c.TIME_OF_CREATION as {customer.timeOfCreation},c.TIME_OF_LAST_UPDATE as {customer.timeOfLastUpdate},c.comments as {customer.comments},c.debid as {customer.debid},c.addressid as {customer.address},c.defaultsortorderid as {customer.defaultSortOrder},c.defaultUnitid as {customer.defaultUnit} FROM CUSTOMERS c
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - flushing session
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - Flushing entities and processing referenced collections
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - Processing unreferenced collections
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - Scheduling collection removes/(re)creates/updates
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionImpl  - Dont need to execute flush
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider  - total checked-out connections: 2
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider  - using pooled JDBC connection, pool size: 0
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.SQL  - SELECT c.id as ID0_,c.companyid as COMPANYID0_,c.parentid as PARENTID0_,c.categoryid as CATEGORYID0_,c.TIME_OF_CREATION as TIME_OF_6_0_,c.TIME_OF_LAST_UPDATE as TIME_OF_5_0_,c.comments as COMMENTS0_,c.debid as DEBID0_,c.addressid as ADDRESSID0_,c.defaultsortorderid as DEFAULT10_0_,c.defaultUnitid as DEFAULT11_0_ FROM CUSTOMERS c
2726180 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
2726190 [AWT-EventQueue-0] DEBUG net.sf.hibernate.loader.Loader  - processing result set
2726190 [AWT-EventQueue-0] DEBUG net.sf.hibernate.type.IntegerType  - returning '1' as column: ID0_
2726190 [AWT-EventQueue-0] DEBUG net.sf.hibernate.loader.Loader  - result row: 1
2726190 [AWT-EventQueue-0] DEBUG net.sf.hibernate.util.JDBCExceptionReporter  - SQL Exception
java.sql.SQLException: Column 'clazz_0_' not found.
   at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
   at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
   at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
   at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
   at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:74)
   at net.sf.hibernate.loader.Loader.getInstanceClass(Loader.java:648)
   at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:569)
   at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
   at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
   at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
   at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at bsh.Reflect.invokeOnMethod(Unknown Source)
   at bsh.Reflect.invokeObjectMethod(Unknown Source)
   at bsh.BSHPrimarySuffix.doName(Unknown Source)
   at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
   at bsh.BSHPrimaryExpression.eval(Unknown Source)
   at bsh.BSHPrimaryExpression.eval(Unknown Source)
   at bsh.Interpreter.eval(Unknown Source)
   at bsh.Interpreter.eval(Unknown Source)
   at bsh.Interpreter.eval(Unknown Source)
   at net.sf.hibern8ide.JavaPage.setSession(JavaPage.java:50)
   at net.sf.hibern8ide.Hibern8IDE$ExecuteJava.actionPerformed(Hibern8IDE.java:1021)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
   at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
   at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
   at java.awt.Component.processMouseEvent(Component.java:5100)
   at java.awt.Component.processEvent(Component.java:4897)
   at java.awt.Container.processEvent(Container.java:1569)
   at java.awt.Component.dispatchEventImpl(Component.java:3615)
   at java.awt.Container.dispatchEventImpl(Container.java:1627)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
   at java.awt.Container.dispatchEventImpl(Container.java:1613)
   at java.awt.Window.dispatchEventImpl(Window.java:1606)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
2726190 [AWT-EventQueue-0] WARN  net.sf.hibernate.util.JDBCExceptionReporter  - SQL Error: 0, SQLState: S0022
2726190 [AWT-EventQueue-0] ERROR net.sf.hibernate.util.JDBCExceptionReporter  - Column 'clazz_0_' not found.
2726190 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
2726190 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
2726190 [AWT-EventQueue-0] DEBUG net.sf.hibernate.util.JDBCExceptionReporter  - SQL Exception
java.sql.SQLException: Column 'clazz_0_' not found.
   at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
   at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
   at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
   at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
   at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:74)
   at net.sf.hibernate.loader.Loader.getInstanceClass(Loader.java:648)
   at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:569)
   at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
   at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
   at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
   at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at bsh.Reflect.invokeOnMethod(Unknown Source)
   at bsh.Reflect.invokeObjectMethod(Unknown Source)
   at bsh.BSHPrimarySuffix.doName(Unknown Source)
   at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
   at bsh.BSHPrimaryExpression.eval(Unknown Source)
   at bsh.BSHPrimaryExpression.eval(Unknown Source)
   at bsh.Interpreter.eval(Unknown Source)
   at bsh.Interpreter.eval(Unknown Source)
   at bsh.Interpreter.eval(Unknown Source)
   at net.sf.hibern8ide.JavaPage.setSession(JavaPage.java:50)
   at net.sf.hibern8ide.Hibern8IDE$ExecuteJava.actionPerformed(Hibern8IDE.java:1021)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
   at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
   at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
   at java.awt.Component.processMouseEvent(Component.java:5100)
   at java.awt.Component.processEvent(Component.java:4897)
   at java.awt.Container.processEvent(Container.java:1569)
   at java.awt.Component.dispatchEventImpl(Component.java:3615)
   at java.awt.Container.dispatchEventImpl(Container.java:1627)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
   at java.awt.Container.dispatchEventImpl(Container.java:1613)
   at java.awt.Window.dispatchEventImpl(Window.java:1606)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
2726190 [AWT-EventQueue-0] WARN  net.sf.hibernate.util.JDBCExceptionReporter  - SQL Error: 0, SQLState: S0022


Hibernate.cfg.xml:

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

   
<hibernate-configuration>
    <session-factory>
      <property name="connection.datasource">java:comp/env/jdbc/vikieedi</property>

       <!--
       <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
       <property name="hibernate.connection.url">jdbc:mysql://localhost/vikie</property>
       <property name="hibernate.connection.username">root</property>
       <property name="hibernate.connection.password">root</property>
      -->
      <!--
      <property name="use_outer_join">true</property>
      -->
      <property name="hibernate.query.substitutions">true 1, false 0</property>
      <property name="show_sql">true</property>
      <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
      <!-- Mapping files -->
       <mapping resource="nl/dennie/vikie/model/Address.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Area.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Category.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/ChainElement.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Condition.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Country.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Customer.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Dossier.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Message.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/EmailAccount.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/MessageAttachment.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/namedqueries.xml"/>
       <mapping resource="nl/dennie/vikie/model/Order.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/OrderDetail.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Product.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Range.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/SortOrder.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Status.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/Unit.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/User.hbm.xml"/>
       <mapping resource="nl/dennie/vikie/model/ZipcodeRange.hbm.xml"/>
    </session-factory>
   
   
</hibernate-configuration>

Hibernate version:
2.1.6

Hope somebody can point out to me what I am doing wrong.

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 12:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you also need to include the discriminator column!

Include ALL columns needed to build the instance from a rowset...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 12:29 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
I am using a joined-subclass. So I don't have a discriminator value column. Is this query not possible in the table-per-subclass strategy?

Thanks for the quick response.

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 12:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ok - then find out what the column clazz_0_ in the exception "java.sql.SQLException: Column 'clazz_0_' not found." points to.

This hints to me that hibernate assumes there should be column called "clazz" (alias to clazz_0_) which is part of the classes tables you are referring.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 12:48 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
I did a full text-search in my Hibernate mapping files and a full-text search in a dump of my SQL scheme and there was no "clazz" reference.
When I searched for "clazz" in the Hibernate codes it occured 318 times. The previous messages in this topic also had a "clazz" and its alias "clazz_0_" error in its Exception, that's why I found this message.
So I don't think I reference "clazz" in my code but Hibernate magically generates it.

I am probably doing something wrong, but I really don't know what.

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 12:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
As you don't provide a simple test case I can't do much more than to suggest you to execute a HQL query: "from Customer" and look at what sql it generates....that should also include a ref to a 'clazz_0_' column.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 1:28 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
I checked the "from Customer" debug data and there was no "clazz" reference. I compiled a simple example to show the error:

Main test class
Code:
public class Test{

   public static void main(String[] args){
      new Test();
   }

   public Test() {
      Session s=null;
      try {
         SessionFactory sf = new Configuration().configure().buildSessionFactory();
         s = sf.openSession();

         List l = s.createSQLQuery("SELECT g.id as {girl.id} from GIRLS g","girl",model.Girl.class).list();

         if(l!=null){
            System.out.println("Number of records in list: " + l.size());
         }

      } catch (HibernateException e) {
         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
      }
      finally{
         try {
            s.close();
         } catch (HibernateException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
      }



   }
}


Hibernate config file
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">


<hibernate-configuration>
   <session-factory>

      <property name="hibernate.query.substitutions">true 1, false 0</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost/test2</property>
      <property name="hibernate.connection.username">root</property>
      <property name="hibernate.connection.password">root</property>

      <property name="show_sql">false</property>
      <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

      <!-- Mapping files -->
      <mapping resource="model/Girl.hbm.xml"/>
   </session-factory>


</hibernate-configuration>

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

<hibernate-mapping package="model"  default-cascade="none">

   <class name="Girl" table="girls" where="deleted = 'false'" >
      <id name="id" type="int" column="id">
         <generator class="identity"/>
      </id>
      <joined-subclass name="HotGirl" table="hotgirls">
         <key column="ID"/>
      </joined-subclass>
   </class>
</hibernate-mapping>

Girl.java
Code:
package model;

import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;


/** @author Hibernate CodeGenerator */
public class Girl implements Serializable {

    /** identifier field */
    private Integer id;

    /** full constructor */
    public Girl() {
    }

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String toString() {
        return new ToStringBuilder(this)
            .append("id", getId())
            .toString();
    }

}

HotGirl.java
Code:
package model;

import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;


/** @author Hibernate CodeGenerator */
public class HotGirl extends Girl implements Serializable {

    /** full constructor */
    public HotGirl() {
    }

    public String toString() {
        return new ToStringBuilder(this)
            .append("id", getId())
            .toString();
    }

}

database scheme generated from hbm2ddl:
Code:
alter table hotgirls drop constraint FKEF1CFD2A91B
drop table if exists girls
drop table if exists hotgirls
create table girls (id integer not null auto_increment, primary key (id))
create table hotgirls (ID integer not null, primary key (ID))
alter table hotgirls add index FKEF1CFD2A91B (ID), add constraint FKEF1CFD2A91B foreign key (ID) references girls (id)


The error only occurs when data is entered in both tables!
Code to insert some values in database :
Code:
insert into girls values(1);
insert into girls values(2);
insert into girls values(3);
insert into hotgirls values(1);


The resulting error:
0 [main] INFO net.sf.hibernate.cfg.Environment - Hibernate 2.1.6
0 [main] INFO net.sf.hibernate.cfg.Environment - hibernate.properties not found
10 [main] INFO net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
20 [main] INFO net.sf.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
20 [main] INFO net.sf.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
621 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath under net/sf/hibernate/
621 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath
701 [main] DEBUG net.sf.hibernate.cfg.Configuration - hibernate.query.substitutions=true 1, false 0
701 [main] DEBUG net.sf.hibernate.cfg.Configuration - hibernate.connection.driver_class=com.mysql.jdbc.Driver
701 [main] DEBUG net.sf.hibernate.cfg.Configuration - hibernate.connection.url=jdbc:mysql://localhost/test2
701 [main] DEBUG net.sf.hibernate.cfg.Configuration - hibernate.connection.username=root
701 [main] DEBUG net.sf.hibernate.cfg.Configuration - hibernate.connection.password=root
701 [main] DEBUG net.sf.hibernate.cfg.Configuration - show_sql=false
711 [main] DEBUG net.sf.hibernate.cfg.Configuration - dialect=net.sf.hibernate.dialect.MySQLDialect
711 [main] DEBUG net.sf.hibernate.cfg.Configuration - null<-org.dom4j.tree.DefaultAttribute@e28b9 [Attribute: name resource value "model/Girl.hbm.xml"]
711 [main] INFO net.sf.hibernate.cfg.Configuration - Mapping resource: model/Girl.hbm.xml
731 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
731 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
941 [main] INFO net.sf.hibernate.cfg.Binder - Mapping class: model.Girl -> girls
1031 [main] DEBUG net.sf.hibernate.cfg.Binder - Mapped property: id -> id, type: integer
1112 [main] INFO net.sf.hibernate.cfg.Binder - Mapping joined-subclass: model.HotGirl -> hotgirls
1112 [main] INFO net.sf.hibernate.cfg.Configuration - Configured SessionFactory: null
1112 [main] DEBUG net.sf.hibernate.cfg.Configuration - properties: {hibernate.connection.password=root, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=D:\libs\j2sdk\v1.4.2_06\jre\bin, java.vm.version=1.4.2_06-b03, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, idea.launcher.port=7535, user.country=NL, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=D:\projects\FirstIdeaProject, java.runtime.version=1.4.2_06-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=D:\libs\j2sdk\v1.4.2_06\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\ddelange\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=D:\libs\j2sdk\v1.4.2_06\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;"C:\Program Files\Symantec\Norton Ghost 2003\";C:\PROGRA~1\IBM\CLIENT~1;C:\PROGRA~1\IBM\CLIENT~1\Shared;C:\PROGRA~1\IBM\CLIENT~1\Emulator;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;"C:\Program Files\Symantec\Norton Ghost 2003\";C:\PROGRA~1\IBM\CLIENT~1;C:\PROGRA~1\IBM\CLIENT~1\Shared;C:\PROGRA~1\IBM\CLIENT~1\Emulator;;C:\cygwin\bin;C:\j2sdk1.4.2_05\bin;D:\eclipse-SDK-3.0.1-win32\eclipse\plugins\org.apache.ant_1.6.2\bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.1, user.home=C:\Documents and Settings\ddelange, user.timezone=, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=windows-1252, java.specification.version=1.4, hibernate.connection.driver_class=com.mysql.jdbc.Driver, show_sql=false, user.name=ddelange, java.class.path=D:\libs\j2sdk\v1.4.2_06\jre\lib\charsets.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jce.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jsse.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\plugin.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\rt.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\sunrsasign.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\dnsns.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\ldapsec.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\localedata.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\sunjce_provider.jar;D:\projects\FirstIdeaProject\vikiestandard\test_classes;D:\projects\FirstIdeaProject\vikiestandard\classes;D:\libs\hibernate\hibernate-2.1.6\lib\commons-logging-1.0.4.jar;D:\libs\log4j\jakarta-log4j-1.2.8\dist\lib\log4j-1.2.8.jar;D:\libs\hibernate\hibernate-2.1.6\hibernate2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-system.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-cache.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jdbc2_0-stdext.jar;D:\libs\hibernate\hibernate-2.1.6\lib\connector.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-pool-1.2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jgroups-2.2.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\ant-1.5.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\oscache-2.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jaas.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-lang-1.0.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\xalan-2.4.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-jmx.jar;D:\libs\hibernate\hibernate-2.1.6\lib\log4j-1.2.8.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-collections-2.1.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\odmg-3.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\c3p0-0.8.4.5.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jta.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-dbcp-1.2.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\junit-3.8.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\concurrent-1.3.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jcs-1.0-dev.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-common.jar;D:\libs\hibernate\hibernate-2.1.6\lib\cglib-full-2.0.2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\swarmcache-1.0rc2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\ehcache-0.9.jar;D:\libs\hibernate\hibernate-2.1.6\lib\xml-apis.jar;D:\libs\hibernate\hibernate-2.1.6\lib\xerces-2.4.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\proxool-0.8.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\ant-optional-1.5.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\dom4j-1.4.jar;D:\libs\mysql-connector-java-3.0.15-ga\mysql-connector-java-3.0.15-ga-bin.jar;D:\libs\mysql\mysql-connector-java-3.0.15-ga\mysql-connector-java-3.0.15-ga-bin.jar;C:\IntelliJ-IDEA-4.5\lib\idea_rt.jar, hibernate.show_sql=false, hibernate.query.substitutions=true 1, false 0, java.vm.specification.version=1.0, java.home=D:\libs\j2sdk\v1.4.2_06\jre, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/test2, user.language=nl, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_06, java.ext.dirs=D:\libs\j2sdk\v1.4.2_06\jre\lib\ext, sun.boot.class.path=D:\libs\j2sdk\v1.4.2_06\jre\lib\rt.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\i18n.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\sunrsasign.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jsse.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jce.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\charsets.jar;D:\libs\j2sdk\v1.4.2_06\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, idea.launcher.library=C:\IntelliJ-IDEA-4.5\bin\breakgen.dll, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, dialect=net.sf.hibernate.dialect.MySQLDialect, sun.cpu.isalist=pentium i486 i386}
1122 [main] INFO net.sf.hibernate.cfg.Configuration - processing one-to-many association mappings
1122 [main] INFO net.sf.hibernate.cfg.Configuration - processing one-to-one association property references
1122 [main] INFO net.sf.hibernate.cfg.Configuration - processing foreign key constraints
1122 [main] DEBUG net.sf.hibernate.cfg.Configuration - resolving reference to class: model.Girl
1322 [main] INFO net.sf.hibernate.dialect.Dialect - Using dialect: net.sf.hibernate.dialect.MySQLDialect
1332 [main] INFO net.sf.hibernate.cfg.SettingsFactory - Maximim outer join fetch depth: 2
1332 [main] INFO net.sf.hibernate.cfg.SettingsFactory - Use outer join fetching: true
1332 [main] INFO net.sf.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
1332 [main] INFO net.sf.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
1342 [main] INFO net.sf.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/test2
1342 [main] INFO net.sf.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=root}
1352 [main] INFO net.sf.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
1352 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
1352 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
1742 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - created connection to: jdbc:mysql://localhost/test2, Isolation Level: 4
1742 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
1742 [main] INFO net.sf.hibernate.cfg.SettingsFactory - Use scrollable result sets: true
1742 [main] INFO net.sf.hibernate.cfg.SettingsFactory - Use JDBC3 getGeneratedKeys(): true
1742 [main] INFO net.sf.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: false
1742 [main] INFO net.sf.hibernate.cfg.SettingsFactory - Query language substitutions: {true=1, false=0}
1742 [main] INFO net.sf.hibernate.cfg.SettingsFactory - cache provider: net.sf.hibernate.cache.EhCacheProvider
1752 [main] INFO net.sf.hibernate.cfg.Configuration - instantiating and configuring caches
1933 [main] INFO net.sf.hibernate.impl.SessionFactoryImpl - building session factory
1933 [main] DEBUG net.sf.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties: {hibernate.connection.password=root, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=D:\libs\j2sdk\v1.4.2_06\jre\bin, java.vm.version=1.4.2_06-b03, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, idea.launcher.port=7535, user.country=NL, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=D:\projects\FirstIdeaProject, java.runtime.version=1.4.2_06-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=D:\libs\j2sdk\v1.4.2_06\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\ddelange\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=D:\libs\j2sdk\v1.4.2_06\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;"C:\Program Files\Symantec\Norton Ghost 2003\";C:\PROGRA~1\IBM\CLIENT~1;C:\PROGRA~1\IBM\CLIENT~1\Shared;C:\PROGRA~1\IBM\CLIENT~1\Emulator;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;"C:\Program Files\Symantec\Norton Ghost 2003\";C:\PROGRA~1\IBM\CLIENT~1;C:\PROGRA~1\IBM\CLIENT~1\Shared;C:\PROGRA~1\IBM\CLIENT~1\Emulator;;C:\cygwin\bin;C:\j2sdk1.4.2_05\bin;D:\eclipse-SDK-3.0.1-win32\eclipse\plugins\org.apache.ant_1.6.2\bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.1, user.home=C:\Documents and Settings\ddelange, user.timezone=, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=windows-1252, java.specification.version=1.4, hibernate.connection.driver_class=com.mysql.jdbc.Driver, show_sql=false, user.name=ddelange, java.class.path=D:\libs\j2sdk\v1.4.2_06\jre\lib\charsets.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jce.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jsse.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\plugin.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\rt.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\sunrsasign.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\dnsns.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\ldapsec.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\localedata.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\ext\sunjce_provider.jar;D:\projects\FirstIdeaProject\vikiestandard\test_classes;D:\projects\FirstIdeaProject\vikiestandard\classes;D:\libs\hibernate\hibernate-2.1.6\lib\commons-logging-1.0.4.jar;D:\libs\log4j\jakarta-log4j-1.2.8\dist\lib\log4j-1.2.8.jar;D:\libs\hibernate\hibernate-2.1.6\hibernate2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-system.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-cache.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jdbc2_0-stdext.jar;D:\libs\hibernate\hibernate-2.1.6\lib\connector.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-pool-1.2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jgroups-2.2.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\ant-1.5.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\oscache-2.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jaas.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-lang-1.0.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\xalan-2.4.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-jmx.jar;D:\libs\hibernate\hibernate-2.1.6\lib\log4j-1.2.8.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-collections-2.1.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\odmg-3.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\c3p0-0.8.4.5.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jta.jar;D:\libs\hibernate\hibernate-2.1.6\lib\commons-dbcp-1.2.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\junit-3.8.1.jar;D:\libs\hibernate\hibernate-2.1.6\lib\concurrent-1.3.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jcs-1.0-dev.jar;D:\libs\hibernate\hibernate-2.1.6\lib\jboss-common.jar;D:\libs\hibernate\hibernate-2.1.6\lib\cglib-full-2.0.2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\swarmcache-1.0rc2.jar;D:\libs\hibernate\hibernate-2.1.6\lib\ehcache-0.9.jar;D:\libs\hibernate\hibernate-2.1.6\lib\xml-apis.jar;D:\libs\hibernate\hibernate-2.1.6\lib\xerces-2.4.0.jar;D:\libs\hibernate\hibernate-2.1.6\lib\proxool-0.8.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\ant-optional-1.5.3.jar;D:\libs\hibernate\hibernate-2.1.6\lib\dom4j-1.4.jar;D:\libs\mysql-connector-java-3.0.15-ga\mysql-connector-java-3.0.15-ga-bin.jar;D:\libs\mysql\mysql-connector-java-3.0.15-ga\mysql-connector-java-3.0.15-ga-bin.jar;C:\IntelliJ-IDEA-4.5\lib\idea_rt.jar, hibernate.show_sql=false, hibernate.query.substitutions=true 1, false 0, java.vm.specification.version=1.0, java.home=D:\libs\j2sdk\v1.4.2_06\jre, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/test2, user.language=nl, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_06, java.ext.dirs=D:\libs\j2sdk\v1.4.2_06\jre\lib\ext, sun.boot.class.path=D:\libs\j2sdk\v1.4.2_06\jre\lib\rt.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\i18n.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\sunrsasign.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jsse.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\jce.jar;D:\libs\j2sdk\v1.4.2_06\jre\lib\charsets.jar;D:\libs\j2sdk\v1.4.2_06\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, idea.launcher.library=C:\IntelliJ-IDEA-4.5\bin\breakgen.dll, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, dialect=net.sf.hibernate.dialect.MySQLDialect, sun.cpu.isalist=pentium i486 i386}
2544 [main] DEBUG net.sf.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
2544 [main] DEBUG net.sf.hibernate.impl.SessionFactoryObjectFactory - registered: 8a8a81f8003d3afc01003d3afff80000 (unnamed)
2544 [main] INFO net.sf.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
2544 [main] DEBUG net.sf.hibernate.impl.SessionFactoryImpl - instantiated session factory
2634 [main] DEBUG net.sf.hibernate.impl.SessionImpl - opened session
2644 [main] DEBUG net.sf.hibernate.impl.SessionImpl - SQL query: SELECT g.id as {girl.id} from GIRLS g
2654 [main] DEBUG net.sf.hibernate.impl.SessionImpl - flushing session
2654 [main] DEBUG net.sf.hibernate.impl.SessionImpl - Flushing entities and processing referenced collections
2654 [main] DEBUG net.sf.hibernate.impl.SessionImpl - Processing unreferenced collections
2654 [main] DEBUG net.sf.hibernate.impl.SessionImpl - Scheduling collection removes/(re)creates/updates
2654 [main] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
2654 [main] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2654 [main] DEBUG net.sf.hibernate.impl.SessionImpl - Dont need to execute flush
2654 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
2654 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
2654 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
2654 [main] DEBUG net.sf.hibernate.SQL - SELECT g.id as id0_ from GIRLS g
2654 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
2674 [main] DEBUG net.sf.hibernate.loader.Loader - processing result set
2684 [main] DEBUG net.sf.hibernate.type.IntegerType - returning '1' as column: id0_
2684 [main] DEBUG net.sf.hibernate.loader.Loader - result row: 1
2694 [main] DEBUG net.sf.hibernate.util.JDBCExceptionReporter - SQL Exception
java.sql.SQLException: Column 'clazz_0_' not found.
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:74)
at net.sf.hibernate.loader.Loader.getInstanceClass(Loader.java:648)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:569)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at Test.<init>(Test.java:32)
at Test.main(Test.java:23)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
2694 [main] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: S0022
2694 [main] ERROR net.sf.hibernate.util.JDBCExceptionReporter - Column 'clazz_0_' not found.
2694 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
2694 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
2704 [main] DEBUG net.sf.hibernate.util.JDBCExceptionReporter - SQL Exception
java.sql.SQLException: Column 'clazz_0_' not found.
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:74)
at net.sf.hibernate.loader.Loader.getInstanceClass(Loader.java:648)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:569)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at Test.<init>(Test.java:32)
at Test.main(Test.java:23)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
2704 [main] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: S0022
2704 [main] ERROR net.sf.hibernate.util.JDBCExceptionReporter - Column 'clazz_0_' not found.
2704 [main] ERROR net.sf.hibernate.util.JDBCExceptionReporter - SQLException occurred
java.sql.SQLException: Column 'clazz_0_' not found.
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:74)
at net.sf.hibernate.loader.Loader.getInstanceClass(Loader.java:648)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:569)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at Test.<init>(Test.java:32)
at Test.main(Test.java:23)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
net.sf.hibernate.JDBCException: SQLException occurred
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3809)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at Test.<init>(Test.java:32)
at Test.main(Test.java:23)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.sql.SQLException: Column 'clazz_0_' not found.
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:74)
at net.sf.hibernate.loader.Loader.getInstanceClass(Loader.java:648)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:569)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
... 8 more
2714 [main] DEBUG net.sf.hibernate.impl.SessionImpl - closing session
2714 [main] DEBUG net.sf.hibernate.impl.SessionImpl - disconnecting session
2714 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
2714 [main] DEBUG net.sf.hibernate.impl.SessionImpl - transaction completion

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 3:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ok - now i tried and ran your testcase (which did not fail...unless one created data)

But then i went and did what I told you, added a "from Girl" HQL and looked at the sql generated:

Code:
select girl0_.id as id, casewhen(girl0__1_.ID is not null, 1,  casewhen(girl0_.id is not null, 0, -1)) as clazz_ from girls girl0_ left outer join hotgirls girl0__1_ on girl0_.id=girl0__1_.ID


See there is "clazz_" used as the discriminator ;)

...and this is actually available to you as an alias through {girl.class}.

There you go ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 18, 2004 12:56 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
Max, thank you very much for your help. It works now. Those queries get pretty complicated using a table per subclass strategy. Is it possible to supply the discriminator value so I can reference it as value for {girl.class} ?

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 18 posts ]  Go to page 1, 2  Next

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.