Dear Hibernate gurus,
The generated SQL below delimits two column names (i.e. password & initial) with double quotes and although MySQL 4.1 seems to handle it o.k., McKoi crashes. Why is Hibernate adding double quotes to some of the column names? Is there a configuration option that addresses this?
Hibernate version: 2.1.7c
Mapping documents:
from etc/hibernate.properties:
## Mckoi SQL
hibernate.dialect net.sf.hibernate.dialect.MckoiDialect
hibernate.connection.driver_class com.mckoi.JDBCDriver
hibernate.connection.url jdbc:mckoi:///
#hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.00/db.conf
hibernate.connection.username <my username>
hibernate.connection.password <my password>
Code between sessionFactory.openSession() and session.close():
taken from eg/org/hibernate/auction/Main.java:
Session s = factory.openSession();
Transaction tx=null;
try {
tx = s.beginTransaction();
List auctions = s.createQuery(
"select new AuctionInfo( item.id, item.description, item.ends, max(bid.amount) ) "
+ "from AuctionItem item "
+ "left join item.bids bid "
+ "group by item.id, item.description, item.ends "
+ "order by item.ends desc"
)
//.setMaxResults(100)
.list();
Iterator iter = auctions.iterator();
while ( iter.hasNext() ) {
AuctionInfo ai = (AuctionInfo) iter.next();
System.out.println(
"Auction: " + ai.getId() + " - " + ai.getDescription() +
", ends: " + ai.getEnds() +
", highest bid: " + ai.getMaxAmount()
);
}
System.out.println();
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
s.close();
}
Full stack trace of any exception that occurs:
[java] 00:53:44,983 WARN JDBCExceptionReporter:57 - SQL Error: 1, SQLState
: null
[java] 00:53:44,993 ERROR JDBCExceptionReporter:58 - Lexical error at line
1, column 435. Encountered: "\"" (34), after : "."
[java] 00:53:44,993 WARN JDBCExceptionReporter:57 - SQL Error: 1, SQLState
: null
[java] 00:53:44,993 ERROR JDBCExceptionReporter:58 - Lexical error at line
1, column 435. Encountered: "\"" (34), after : "."
[java] net.sf.hibernate.exception.GenericJDBCException: Could not execute q
uery
[java] at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecif
icException(SQLStateConverter.java:81)
[java] at net.sf.hibernate.exception.SQLStateConverter.convert(SQLState
Converter.java:70)
[java] at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCEx
ceptionHelper.java:30)
[java] at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:41
10)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1556)
[java] at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
[java] at org.hibernate.auction.Main.viewAllAuctionsSlow(Main.java:86)
[java] at org.hibernate.auction.Main.main(Main.java:366)
[java] Caused by: com.mckoi.database.jdbc.MSQLException: Lexical error at l
ine 1, column 435. Encountered: "\"" (34), after : "."
[java] at com.mckoi.database.jdbc.RemoteDatabaseInterface.execQuery(Rem
oteDatabaseInterface.java:280)
[java] at com.mckoi.database.jdbc.MConnection.executeQuery(MConnection.
java:453)
[java] at com.mckoi.database.jdbc.MConnection.executeQueries(MConnectio
n.java:436)
[java] at com.mckoi.database.jdbc.MStatement.executeQueries(MStatement.
java:193)
[java] at com.mckoi.database.jdbc.MStatement.executeQuery(MStatement.ja
va:167)
[java] at com.mckoi.database.jdbc.MPreparedStatement.executeQuery(MPrep
aredStatement.java:199)
[java] at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.ja
va:88)
[java] at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
[java] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
[java] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCol
lections(Loader.java:133)
[java] at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
[java] at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
[java] at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.jav
a:854)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
[java] ... 3 more
[java] Exception in thread "main"
Name and version of the database you are using: McKoi 1.0.3
The generated SQL (show_sql=true):
[java] Hibernate: select auctionite0_.id as id0_, bids1_.id as id1_, user2_
.id as id2_, auctionite0_.description as descript2_0_, auctionite0_.ends as ends
0_, auctionite0_.condition as condition0_, auctionite0_.seller as seller0_, auct
ionite0_.successfulBid as successf6_0_, bids1_.isBuyNow as isBuyNow1_, bids1_.am
ount as amount1_, bids1_.datetime as datetime1_, bids1_.bidder as bidder1_, bids
1_.item as item1_, user2_.userName as userName2_, user2_."password" as y3_2_, us
er2_.email as email2_, user2_.firstName as firstName2_, user2_."initial" as y6_2
_, user2_.lastName as lastName2_, bids1_.item as item__, bids1_.id as id__ from
AuctionItem auctionite0_ left outer join Bid bids1_ on auctionite0_.id=bids1_.it
em left outer join AuctionUser user2_ on bids1_.bidder=user2_.id order by aucti
onite0_.ends desc
Debug level Hibernate log excerpt: info
Any help in determining how to avoid this problem would be much appreciated.
Thanks!
JAB
|