[Hibernate-JIRA] Commented: (HHH-956) MSSQL: Distinct queries require all ORDER BY attributes to be selected.
by vikas (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-956?page=co... ]
vikas commented on HHH-956:
---------------------------
We also have same issue for mssql:
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select distinct this_.ID as y0_ from CSMenuNode this_ left outer join CSMenuNode parentnode1_ on this_.CSParentNodeID=parentnode1_.ID where parentnode1_.ID is null order by this_.DisplayOrder asc]; SQL state [S1000]; error code [145]; ORDER BY items must appear in the select list if SELECT DISTINCT is specified.; nested exception is java.sql.SQLException: ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:120)
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:276)
org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:974)
PLease let me know how to reslove this issue
> MSSQL: Distinct queries require all ORDER BY attributes to be selected.
> -----------------------------------------------------------------------
>
> Key: HHH-956
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-956
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.1 beta 2
> Environment: Running HB 3.0.5 but I tried this on the 3.1 beta 3 and got the same error. DB: MS SQL Server 2000 on Windows 2003 Server, JDK 1.4.2_05
> Reporter: Shanon Levenherz
> Attachments: order-by-bug.zip
>
>
> Using Criteria queries with a Distinct projection AND an ORDER BY clause with Microsoft SQL Server cause the following SQL error:
> Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
> this is the culprit query:
> 2005-09-14 11:12:47,570 DEBUG org.hibernate.SQL - select distinct this_.content_id as y0_ from iwsc_content this_ left outer join iwsc_news this_1_ on this_.content_id=this_1_.content_id left outer join iwsc_event this_2_ on this_.content_id=this_2_.content_id left outer join iwsc_document this_3_ on his_.content_id=this_3_.content_id inner join iwsc_content_category categories3_ on this_.content_id=categories3_.content_id inner join iwsc_category category1_ on categories3_.category_id=category1_.category_id where (this_.expiration_date is null or this_.expiration_date>?) and category1_.category_id in (?, ?, ?, ?) and this_.branch in (?) order by this_.creation_date desc
> 2005-09-14 11:12:47,570 DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
> 2005-09-14 11:12:47,570 DEBUG org.hibernate.type.TimestampType - binding '2005-09-14 00:00:00' to parameter: 1
> 2005-09-14 11:12:47,580 DEBUG org.hibernate.type.LongType - binding '100000005' to parameter: 2
> 2005-09-14 11:12:47,580 DEBUG org.hibernate.type.LongType - binding '100000010' to parameter: 3
> 2005-09-14 11:12:47,580 DEBUG org.hibernate.type.LongType - binding '100000015' to parameter: 4
> 2005-09-14 11:12:47,580 DEBUG org.hibernate.type.LongType - binding '100000020' to parameter: 5
> 2005-09-14 11:12:47,580 DEBUG org.hibernate.type.StringType - binding '/default/main/solutions/SalesSolution' to parameter: 6
> 2005-09-14 11:12:47,600 DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
> 2005-09-14 11:12:47,600 DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
> and this is how i fixed it ( added in the creation date in the select )-- note that this isn't in code, i just did it in sql query analyzer.
> select distinct this_.content_id as y0_, this_.creation_date from iwsc_content this_ left outer join iwsc_news this_1_ on this_.content_id=this_1_.content_id left outer join iwsc_event this_2_ on this_.content_id=this_2_.content_id left outer join iwsc_document this_3_ on this_.content_id=this_3_.content_id inner join iwsc_content_category categories3_ on this_.content_id=categories3_.content_id inner join iwsc_category category1_ on categories3_.category_id=category1_.category_id where category1_.category_id in (100000005,100000010,100000015,100000020) and this_.branch in ('/default/main/solutions/SalesSolution') order by this_.creation_date desc
> in attachment:
> tomcat_out.log -- full debug on.
> code.txt - java snippets of how i'm building and executing the criteria.
> mapping_files.zip - the hbm's used to map... only Content and Category should apply here.
> please let me know if you need any further information.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[Hibernate-JIRA] Commented: (HHH-1319) Hibernate 3.1 does not analyze queries with a certain depth anymore
by Gareth Chapman (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1319?page=c... ]
Gareth Chapman commented on HHH-1319:
-------------------------------------
This recently caught me out too. Is there a plan to generate a more meaningful error?
> Hibernate 3.1 does not analyze queries with a certain depth anymore
> -------------------------------------------------------------------
>
> Key: HHH-1319
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1319
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.1
> Environment: Linux, jdk 1.5, Hibernate 3.1, Oracle 10g
> Reporter: Erik Heckert
> Attachments: testcase.tar
>
>
> A query like the one
> from Dispo.Hibernate.Test.A as a where a.ptrB.ptrC.Oid >= :oid
> leads to a NullPointerException when using Hibernate 3.1. The same query runs without a problem against Hibernate 3.0.5.
> When breaking down the where clause to "a.ptrB.Oid = ptrC.Oid and ptrC.Oid = :oid" the query works.
> The stack trace is:
> [java] java.lang.NullPointerException
> [java] at org.hibernate.hql.ast.tree.DotNode.getColumns(DotNode.java:97)
> [java] at org.hibernate.hql.ast.tree.DotNode.initText(DotNode.java:210)
> [java] at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:204)
> [java] at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
> [java] at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
> [java] at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:660)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1213)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4022)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3628)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1756)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:774)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:575)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:279)
> [java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:227)
> [java] at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
> [java] at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
> [java] at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105)
> [java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
> [java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:53)
> [java] at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
> [java] at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
> [java] at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
> [java] at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1540)
> [java] at Dispo.Hibernate.Test.QueryABC.main(QueryABC.java:32)
> I'll attach the Java files I've used for this test case.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[Hibernate-JIRA] Commented: (HHH-1909) Incomplete insert and update using <<insert="false" update="false">>
by Karol Nowak (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909?page=c... ]
Karol Nowak commented on HHH-1909:
----------------------------------
I had the same problem. This is indeed irritating. Another solution is to set the properties accordingly in the setter for the associations, based on the other object. This, however, will break if the second object is initialized after the connection is set.
> Incomplete insert and update using <<insert="false" update="false">>
> --------------------------------------------------------------------
>
> Key: HHH-1909
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0 final
> Reporter: Peppe
> Priority: Critical
>
> Hi, I've seen lots of people have problems using complex mappings.
> This is my situation, I've three mappings:
> <hibernate-mapping>
> <class name="unibiblio.dati.anagrafica.DAO.Persone" table="persone">
> <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.PersoneId">
> <key-property name="idUtente" type="java.lang.Integer">
> <column name="id_utente" />
> </key-property>
> <key-property name="codbib" type="java.lang.Integer">
> <column name="codbib" />
> </key-property>
> </composite-id>
> <many-to-one name="dizTitolidistudio" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" />
> <column name="codice_titolostudio" length="1" />
> </many-to-one>
> <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" fetch="select">
> <column name="lingua" length="2" />
> </many-to-one>
> <many-to-one name="dizProfessioni" class="unibiblio.dati.anagrafica.DAO.DizProfessioni" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" />
> <column name="codprofessione" length="2" not-null="true" />
> </many-to-one>
> <property name="userName" type="string">
> <column name="user_name" length="30" />
> </property>
> <property name="password" type="string">
> <column name="password" length="30" />
> </property>
> .
> .
> .
> .
> .
> .
> </class>
> </hibernate-mapping>
> <hibernate-mapping>
> <class name="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" table="diz_titolidistudio">
> <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudioId">
> <key-property name="lingua" type="string">
> <column name="lingua" length="2" />
> </key-property>
> <key-property name="codiceTitolostudio" type="string">
> <column name="codice_titolostudio" length="1" />
> </key-property>
> </composite-id>
> <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" not-null="true" />
> </many-to-one>
> <property name="titolo" type="string">
> <column name="titolo" length="50" not-null="true" />
> </property>
> <set name="persones" inverse="true">
> <key>
> <column name="lingua" length="2" />
> <column name="codice_titolostudio" length="1" />
> </key>
> <one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
> </set>
> </class>
> </hibernate-mapping>
> <hibernate-mapping>
> <class name="unibiblio.dati.anagrafica.DAO.DizProfessioni" table="diz_professioni">
> <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizProfessioniId">
> <key-property name="lingua" type="string">
> <column name="lingua" length="2" />
> </key-property>
> <key-property name="codprofessione" type="string">
> <column name="codprofessione" length="2" />
> </key-property>
> </composite-id>
> <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" not-null="true" />
> </many-to-one>
> <property name="professione" type="string">
> <column name="professione" length="50" />
> </property>
> <set name="persones" inverse="true">
> <key>
> <column name="lingua" length="2" />
> <column name="codprofessione" length="2" not-null="true" />
> </key>
> <one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
> </set>
> </class>
> </hibernate-mapping>
> The problem is when I try to insert a new persone it make an incomplete SQL statement because
> <<update="false" insert="false">> in <many-to-one name="dizTitolidistudio"> and <many-to-one name="dizProfessioni">
> causes hiding setting of columns "codice_titolostudio" and "codprofessione" in the generated SQL
> Deleting that tag, of course, give me the exception
> ERROR [STDERR] org.hibernate.MappingException: Repeated column in mapping for entity: unibiblio.dati.anagrafica.DAO.Persone column: lingua (should be mapped with insert="false" update="false")
>
> I workarounded this extracting "codice_titolostudio" and "codprofessione" as properties in Persone and setting them with
> classes but I don't like this. Am I wrong or is it a bug?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[Hibernate-JIRA] Created: (HHH-2610) Invalid SQL generation for dynamic filter
by Calin Pavel (JIRA)
Invalid SQL generation for dynamic filter
-----------------------------------------
Key: HHH-2610
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2610
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Environment: Windows XP, database MS-SQL and MySQL, Hibernate 3.2.3
Reporter: Calin Pavel
I have a simple object model composed from three classes with their relationship as described above by mapping file. One of them is the superclass for the other two, and I have defined a filter for it. If filter is activated and try to retrieve an instance of subclass, generated SQL is invalid and an exception is thrown (see logs below).
Hibernate: 3.2.3
DB: MySQL 5.0.27, MS-SQL 2000, ...
Mappings:
<hibernate-mapping>
<class name="test.model.Entity" table="entity">
<id name="id" column="id" type="long">
<generator class="identity" />
</id>
<property name="siteId" type="string">
<column name="siteId" />
</property>
<joined-subclass name="test.model.User" table="user">
<key column="id" />
<property name="FirstName" type="string">
<column name="firstName" />
</property>
<property name="LastName" type="string">
<column name="lastName" />
</property>
<one-to-one name="Account" property-ref="User" cascade="delete" />
</joined-subclass>
<joined-subclass name="test.model.Account" table="account">
<key column="id" />
<property name="name" type="string">
<column name="name" />
</property>
<many-to-one name="User" column="user_id" class="test.model.User" unique="true" not-null="true" />
</joined-subclass>
<filter name="siteIdFilter" condition="siteId=:siteId" />
</class>
<filter-def name="siteIdFilter">
<filter-param name="siteId" type="string" />
</filter-def>
</hibernate-mapping>
Code:
Session session = HibernateUtils.currentSession();
session.enableFilter("siteIdFilter").setParameter("siteId", "opp");
User user = (User) session.get(User.class, new Long(3));
session.close();
Stacktrace:
11:18:16,475 DEBUG DefaultLoadEventListener:143 - loading entity: [test.model.User#3]
11:18:16,475 DEBUG DefaultLoadEventListener:290 - attempting to resolve: [test.model.User#3]
11:18:16,475 DEBUG DefaultLoadEventListener:326 - object not resolved in any cache: [test.model.User#3]
11:18:16,475 DEBUG BasicEntityPersister:2467 - Materializing entity: [test.model.User#3]
11:18:16,522 DEBUG EntityLoader:95 - Static select for entity test.model.User: select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=:siteIdFilter.siteId left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?
11:18:16,522 DEBUG Loader:1340 - loading entity: [test.model.User#3]
11:18:16,522 DEBUG AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:18:16,522 DEBUG SQL:324 - select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=? left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?
Hibernate: select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=? left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?
11:18:16,522 DEBUG AbstractBatcher:378 - preparing statement
11:18:16,553 DEBUG StringType:59 - binding 'opp' to parameter: 1
11:18:16,553 DEBUG LongType:59 - binding '3' to parameter: 2
11:18:16,569 DEBUG AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:18:16,569 DEBUG AbstractBatcher:416 - closing statement
11:18:16,569 DEBUG JDBCExceptionReporter:63 - could not load an entity: [test.model.User#3] [select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=:siteIdFilter.siteId left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?]
java.sql.SQLException: Unknown column 'account1_1_.siteId' in 'on clause'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at test.FilterMain.runMain2(FilterMain.java:47)
at test.FilterMain.main(FilterMain.java:33)
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:90)
11:18:16,569 WARN JDBCExceptionReporter:71 - SQL Error: 1054, SQLState: 42S22
11:18:16,569 ERROR JDBCExceptionReporter:72 - Unknown column 'account1_1_.siteId' in 'on clause'
11:18:16,569 INFO DefaultLoadEventListener:85 - Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [test.model.User#3]
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1359)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at test.FilterMain.runMain2(FilterMain.java:47)
at test.FilterMain.main(FilterMain.java:33)
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:90)
Caused by: java.sql.SQLException: Unknown column 'account1_1_.siteId' in 'on clause'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
... 17 more
11:18:16,584 DEBUG JDBCContext:322 - after autocommit
org.hibernate.exception.SQLGrammarException: could not load an entity: [test.model.User#3]
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1359)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at test.FilterMain.runMain2(FilterMain.java:47)
at test.FilterMain.main(FilterMain.java:33)
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:90)
Caused by: java.sql.SQLException: Unknown column 'account1_1_.siteId' in 'on clause'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
... 17 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[Hibernate-JIRA] Created: (EJB-351) Optimistic Locking Deadlocks with Application Manged EM in Threaded Environment
by Allen Harvey (JIRA)
Optimistic Locking Deadlocks with Application Manged EM in Threaded Environment
-------------------------------------------------------------------------------
Key: EJB-351
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-351
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.2.GA
Environment: Annotations 3.3.1.GA
Core 3.2
Windows XP Pro
Netbeans 6.01
Sun JDK 1.6.04
MSSQL 2000
Reporter: Allen Harvey
Attachments: hibernateJPAtest.zip
I have posted about this issue in the forums here: http://forum.hibernate.org/viewtopic.php?t=985460, but have received no reply. I am hoping it is a bug, and not a mistake on my part.
When using an application managed entity manager in a concurrent environment, the database is deadlocking. The scenario is this:
Create several bank accounts
Persist them
Create many (10) clients
Clients simultaneously transfer money randomly among the accounts as fast as possible
Each transfer between two accounts is a transaction
Optimistic lock exceptions are expected and handled (a new em is created and the transaction retried).
Depsite having annotated the account entity (@Version), settings ordered updates, using a thread-local entity manager, and setting the MS SQL 2000 db to read committed, the database deadlocks.
I have created a small sample application that reproduces the problem, it is attached. Finally, I tried this on Mysql 5.x as well, and that database also deadlocked, so it doesn't appear to be a database driver issue.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[Hibernate-JIRA] Created: (HHH-3222) named query string manipulation
by Szczepan Faber (JIRA)
named query string manipulation
-------------------------------
Key: HHH-3222
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3222
Project: Hibernate3
Issue Type: New Feature
Reporter: Szczepan Faber
I'd like to manipulate query string that lives in named query (xml file).
Java does not support multiline Strings - In order to keep queries readable we use named queries that live in xml files. Sometimes those queries are nearly the same (single table name is different, etc). We would like to avoid keeping two instances of nearly the same queries to avoid duplication of sql, tests and minimize bugs.
Here is an example from our application (2 years/30 devs). We have a concept of draft and live, e.g theoretical PAGE table spans into LIVE_PAGE and DRAFT_PAGE (and for many reasons we cannot change this pattern). We have many complex queries (complex joins, etc.) that are identical with one little difference: one joins to DRAFT table, the other one to LIVE table.
The interface I was thinking about is (just an example):
sessionFactory.getCurrentSession().getNamedQuery("foo", *QueryTransformer*)
interface QueryTransformer {
String transform(String query);
}
Then, we could write our named queries like that:
<sql-query name="foo">
...
join {draftOrLive}_PAGE on ...
...
and implement our own QueryTransformer that would resolve table name properly to LIVE_PAGE or DRAFT_PAGE
Can you please give me some feedback on that feature? Probably we will implement it anyway but if you see some gotchas/issues with the idea then please let me know.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[Hibernate-JIRA] Updated: (HHH-1830) Error during parse query on MS SQL
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1830?page=c... ]
Steve Ebersole updated HHH-1830:
--------------------------------
Priority: Major (was: Critical)
Assignee: Steve Ebersole
Component/s: core
> Error during parse query on MS SQL
> ----------------------------------
>
> Key: HHH-1830
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1830
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.2, 3.2.0.cr2
> Environment: Microsoft SQL Server 2000, Windows XP, JDK 1.5 Update 4
> Reporter: Den Raskovalov
> Assignee: Steve Ebersole
> Attachments: hibernateBug.tar.gz, hibernateBug.zip
>
>
> HQL: select deal, items.dateBegin, client.Title from " + CoreDeal.class.getName() + " deal left join deal.stagesWorkflowInstance.history.items items, " + CoreClient.class.getName() + " client where stageResponsible=:stageResponsible and items.index=maxindex(items) and deal.parent=client and deal.stagesWorkflowInstance.Stage.showOnPersonalPage=1
> It works normally on Oracle, but on MS SQL produces:
> Error: String index out of range: -5
> [java.lang.StringIndexOutOfBoundsException]
> java.lang.String.substring(String.java:1768)
> java.lang.String.substring(String.java:1735)
> org.hibernate.hql.CollectionSubqueryFactory.createCollectionSubquery(CollectionSubqueryFactory.java:32)
> org.hibernate.hql.ast.tree.FromElementType.toColumns(FromElementType.java:301)
> org.hibernate.hql.ast.tree.FromElementType.toColumns(FromElementType.java:291)
> org.hibernate.hql.ast.tree.FromElement.toColumns(FromElement.java:377)
> org.hibernate.hql.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:115)
> org.hibernate.hql.ast.tree.MethodNode.collectionProperty(MethodNode.java:95)
> org.hibernate.hql.ast.tree.MethodNode.resolve(MethodNode.java:44)
> org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:844)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:2324)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1285)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4032)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3521)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1686)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1683)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1683)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
> org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
> org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:227)
> org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:159)
> org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:110)
> org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)
> org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)
> org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
> org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
> org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
> org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1612)
> ru.naumen.crm2.bobjects.deal.CoreDealHibernateHandler.listAllDealsWithSortDataByResponsible(CoreDealHibernateHandler.java:109)
> ru.naumen.crm2.ui.tlc.CoreEmployeeTableListController.listMyDealsSorted(CoreEmployeeTableListController.java:70)
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months