精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2003-12-23
中写到: The supported join types are borrowed from ANSI SQL inner join left outer join right outer join full join (not usually useful) 可我自己测试老不通过(例子是Animal与Cat的一对多的例子): 语句如: select animal from Animal as animal left outer join fetch animal.cats where animal.id='1001' 另外我曾经下载hibernate参考手册第十一章:A Worked Example 的例子进行测试,也出现同样的错误信息. 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2003-12-23
另外,hibernate参考手册中有这样的注释
Note that, in the current implementation, only one collection role may be fetched in a query. Note also that the fetch construct may not be used in queries called using scroll() or iterate(). 而我返回的是List,所以我觉得原因不应该是iterate(),至于scroll(),我还不知道是什么意思,不知道是不是错在这里? |
|
返回顶楼 | |
发表时间:2003-12-23
可能映射错了。
|
|
返回顶楼 | |
发表时间:2003-12-23
可我照抄hibernate参考手册第十一章:A Worked Example
的例子也出错: 而在 BlogMain中 方法:exportTables(),createBlog()等都能正确运行 而getBlogAndAllItems(),listAllBlogNamesAndItemCounts()等只要用到 join 的就报错: Hibernate: select blog0_.BLOG_ID as BLOG_ID0_, items1_.BLOG_ITEM_ID as BLOG_ITEM_ID1_, blog0_.NAME as NAME0_, items1_.TITLE as TITLE1_, items1_.TEXT as TEXT1_, items1_.DATE_TIME as DATE_TIME1_, items1_.BLOG_ID as BLOG_ID1_, items1_.BLOG_ITEM_ID as BLOG_ITE1___, items1_.BLOG_ID as BLOG_ID__ from luomi.BLOGS blog0_ left outer join luomi.BLOG_ITEMS items1_ on blog0_.BLOG_ID=items1_.BLOG_ID where (blog0_.BLOG_ID=? ) order by items1_.DATE_TIME (util.JDBCExceptionReporter 38 ) SQL Error: 933, SQLState: 42000 (util.JDBCExceptionReporter 46 ) ORA-00933: SQL 命令未正确结束 (util.JDBCExceptionReporter 37 ) Could not execute query java.sql.SQLException: ORA-00933: SQL 命令未正确结束 at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208) at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543) at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405) at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643) at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1674) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:314) at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:71) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:551) at net.sf.hibernate.loader.Loader.doFind(Loader.java:140) at net.sf.hibernate.loader.Loader.find(Loader.java:620) at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343) at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:76) at com.eg.BlogMain.getBlogAndAllItems(BlogMain.java:202) at com.eg.BlogMain.main(BlogMain.java:291) |
|
返回顶楼 | |
发表时间:2003-12-23
Dialect设置错了吧。
|
|
返回顶楼 | |
发表时间:2003-12-23
hibernate.cfg.xml的设置如下 , 不应该有错 , 我都做了很多其他方面的测试了 , 都能通过
<?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.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:hibeTest</property> <property name="hibernate.connection.username">luomi</property> <property name="hibernate.connection.password">110809</property> <property name="hibernate.connection.pool.size">20</property> <property name="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</property> <!-- Mapping files --> <mapping resource="com/test/hibernate/be/Cat.hbm.xml"/> <mapping resource="com/test/hibernate/be/Animal.hbm.xml"/> <mapping resource="com/test/hibernate/be/Classes.hbm.xml"/> <mapping resource="com/test/hibernate/be/Course.hbm.xml"/> <mapping resource="com/test/hibernate/be/Student.hbm.xml"/> <mapping resource="com/test/hibernate/be/Address.hbm.xml"/> <mapping resource="com/eg/BlogItem.hbm.xml"/> <mapping resource="com/eg/Blog.hbm.xml"/> </session-factory> </hibernate-configuration> |
|
返回顶楼 | |
发表时间:2003-12-23
不知道跟属性文件的配置有没有关系?
|
|
返回顶楼 | |
发表时间:2003-12-23
你的oracle什么版本?支持left outer join这种形式的外联接吗?
|
|
返回顶楼 | |
发表时间:2003-12-23
Oracle 的版本是8.1 , Oracle不常用, 不算很熟, 不过也不至于不支持left outer join吧!!
|
|
返回顶楼 | |
发表时间:2003-12-23
Oracle8.1不支持这种形式吧,而是支持(+)这种形式。
把Dialect改成net.sf.hibernate.dialect.OracleDialect |
|
返回顶楼 | |