-->
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.  [ 3 posts ] 
Author Message
 Post subject: second try: hibernate, firebird and "select from select
PostPosted: Thu Nov 10, 2005 9:34 am 
Newbie

Joined: Thu May 05, 2005 5:54 am
Posts: 17
Hi have a problem with a "table per concrete class" inheritance mapping using firebird 1.5 and hibernate 3.0.5.
When i select data from tables Hibernate generates a query that does not work with firebird. The query uses the syntax "select * from (select ...) that is not supported on firebird 1.5. Is there a way to tell Hibernate to use some other method to select data from that "mapping"?

Hibernate version:
3.0.5
Mapping documents:
Code:
<hibernate-mapping>
    <class name="testhibernate.Plottable">
        <id name="id" column="PL_ID" type="long">
            <generator class="native">
                <param name="sequence">PLOTTABLE_ID</param>
            </generator>
        </id>
        <union-subclass name="testhibernate.Arco" table="ARCO">
            <property name="cx" column="AR_CX"/>
        </union-subclass>
        <union-subclass name="testhibernate.Linea" table="LINEA">
            <property name="x1" column="LI_X1"/>
        </union-subclass>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
tx = session.beginTransaction();
List ppp = session.createQuery("from Plottable").list();
it = ppp.iterator();
  while(it.hasNext()) {
    Plottable p = it.next();
    System.out.println("" + p);
  }
tx.commit();


Full stack trace of any exception that occurs:
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at testhibernate.Main.main(Main.java:55)
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 129
select
at org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:88)
at org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:34)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:701)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:232)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:396)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:334)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:88)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
at org.hibernate.loader.Loader.doQuery(Loader.java:390)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 6 more
Java Result: 1
Name and version of the database you are using:
Firebird 1.5
The generated SQL (show_sql=true):
Hibernate: select plottable0_.PL_ID as PL1_, plottable0_.AR_CX as AR1_2_, plottable0_.LI_X1 as LI1_3_, plottable0_.clazz_ as clazz_ from ( select null as AR_CX, null as LI_X1, PL_ID, 0 as clazz_ from Plottable union select AR_CX, null as LI_X1, PL_ID, 1 as clazz_ from ARCO union select null as AR_CX, LI_X1, PL_ID, 2 as clazz_ from LINEA ) plottable0_
WARN - SQL Error: 335544569, SQLState: HY000
ERROR - GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 129
select
WARN - SQL Error: 335544569, SQLState: HY000
ERROR - GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 129
select
Debug level Hibernate log excerpt:
DEBUG - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (Plottable,ARCO,LINEA)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'plottable0_.PL_ID as PL1_' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=( select null as AR_CX, null as LI_X1, PL_ID, 0 as clazz_ from Plottable union select AR_CX, null as LI_X1, PL_ID, 1 as clazz_ from ARCO union select null as AR_CX, LI_X1, PL_ID, 2 as clazz_ from LINEA ),tableAlias=plottable0_,colums={,className=testhibernate.Plottable}}}
| \-[SQL_TOKEN] SqlFragment: 'plottable0_.AR_CX as AR1_2_, plottable0_.LI_X1 as LI1_3_, plottable0_.clazz_ as clazz_'
\-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[plottable0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
\-[FROM_FRAGMENT] FromElement: '( select null as AR_CX, null as LI_X1, PL_ID, 0 as clazz_ from Plottable union select AR_CX, null as LI_X1, PL_ID, 1 as clazz_ from ARCO union select null as AR_CX, LI_X1, PL_ID, 2 as clazz_ from LINEA ) plottable0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=( select null as AR_CX, null as LI_X1, PL_ID, 0 as clazz_ from Plottable union select AR_CX, null as LI_X1, PL_ID, 1 as clazz_ from ARCO union select null as AR_CX, LI_X1, PL_ID, 2 as clazz_ from LINEA ),tableAlias=plottable0_,colums={,className=testhibernate.Plottable}}

DEBUG - throwQueryException() : no errors
DEBUG - HQL: from testhibernate.Plottable
DEBUG - SQL: select plottable0_.PL_ID as PL1_, plottable0_.AR_CX as AR1_2_, plottable0_.LI_X1 as LI1_3_, plottable0_.clazz_ as clazz_ from ( select null as AR_CX, null as LI_X1, PL_ID, 0 as clazz_ from Plottable union select AR_CX, null as LI_X1, PL_ID, 1 as clazz_ from ARCO union select null as AR_CX, LI_X1, PL_ID, 2 as clazz_ from LINEA ) plottable0_
DEBUG - throwQueryException() : no errors
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select plottable0_.PL_ID as PL1_, plottable0_.AR_CX as AR1_2_, plottable0_.LI_X1 as LI1_3_, plottable0_.clazz_ as clazz_ from ( select null as AR_CX, null as LI_X1, PL_ID, 0 as clazz_ from Plottable union select AR_CX, null as LI_X1, PL_ID, 1 as clazz_ from ARCO union select null as AR_CX, LI_X1, PL_ID, 2 as clazz_ from LINEA ) plottable0_
Hibernate: select plottable0_.PL_ID as PL1_, plottable0_.AR_CX as AR1_2_, plottable0_.LI_X1 as LI1_3_, plottable0_.clazz_ as clazz_ from ( select null as AR_CX, null as LI_X1, PL_ID, 0 as clazz_ from Plottable union select AR_CX, null as LI_X1, PL_ID, 1 as clazz_ from ARCO union select null as AR_CX, LI_X1, PL_ID, 2 as clazz_ from LINEA ) plottable0_
DEBUG - preparing statement
DEBUG - SQL Exception
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 129
select


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 2:17 am 
Newbie

Joined: Tue Jan 10, 2006 3:57 am
Posts: 2
Location: Lithuania, Vilnius
you can create a view and map it like a table.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 4:48 am 
Newbie

Joined: Thu May 05, 2005 5:54 am
Posts: 17
uh uh. i just forget to have this topic open.

btw almost all the problems can be solved switching to firebird 2.0 that's not yet in stable release but offers all the feature needed to use union-subclass


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