[Hibernate-JIRA] Created: (HHH-3992) SQLServer "contains" boolean predicate not handled in HQL
by Scott Van Wart (JIRA)
SQLServer "contains" boolean predicate not handled in HQL
---------------------------------------------------------
Key: HHH-3992
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3992
Project: Hibernate Core
Issue Type: Improvement
Components: query-hql
Affects Versions: 3.3.2, 3.3.1
Environment: Hibernate core 3.3.1, JDK 1.6, SQLServer 2003
Reporter: Scott Van Wart
The following HQL:
select pp from Product pp where CONTAINS( pp.keywords, :keywords )
Will throw this exception:
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: ( near line 1, column 33 [select pp from Product pp where CONTAINS( pp.keywords, :keywords )]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:258)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
I tried changing it to this:
select pp from Product pp where CONTAINS( pp.keywords, :keywords ) = TRUE
But then SQL Server doesn't like it (it produces SQL like "CONTAINS(pkgproduct0_.keywords, ?)=1":
org.hibernate.exception.SQLGrammarException: could not execute query using scroll
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '='.
--
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
14 years, 4 months
[Hibernate-JIRA] Created: (HHH-3002) database field name 'version' causes ClassCastException while building session factory
by Patrick Burke (JIRA)
database field name 'version' causes ClassCastException while building session factory
--------------------------------------------------------------------------------------
Key: HHH-3002
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3002
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5, Java 1.6.0_03, MySQL 5.0.41
Reporter: Patrick Burke
Attachments: out.hib4
When a database table contains a field named 'version', like his one:
DROP TABLE IF EXISTS `tester`.`software_package`;
CREATE TABLE `tester`.`software_package` (
`software_id` int(11) NOT NULL auto_increment,
`version` varchar(100) default NULL,
`name` varchar(100) default NULL,
`root_file_id` int(11) default NULL,
PRIMARY KEY (`software_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
The following error is thrown:
[java] Initial SessionFactory creation failed.java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at util.HibernateUtil.<clinit>(Unknown Source)
[java] at events.EventManager.listNodes(Unknown Source)
[java] at events.EventManager.main(Unknown Source)
[java] Caused by: java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType
[java] at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:84)
[java] at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:168)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
[java] at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
[java] at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
[java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
[java] ... 3 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
14 years, 4 months
[Hibernate-JIRA] Created: (HHH-4036) EntityMetamodel entityNameByInheritenceClassNameMap field used inconsistently
by Jeremy Stone (JIRA)
EntityMetamodel entityNameByInheritenceClassNameMap field used inconsistently
-----------------------------------------------------------------------------
Key: HHH-4036
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4036
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Reporter: Jeremy Stone
After upgrading (from 3.3.0.SP1) to 3.3.2.GA we have started getting the follow stack trace logged:
org.hibernate.HibernateException: Unable to resolve entity name from Class [com.cyclone.netPrefect.admin.restriction.complex.TimeSpanRestrictionItemEntity] expected instance/subclass of [RestrictionItem]
at org.hibernate.tuple.entity.PojoEntityTuplizer.determineConcreteSubclassEntityName(PojoEntityTuplizer.java:363)
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3643)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1375)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:535)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:103)
... etc, etc
The com.cyclone.netPrefect.admin.restriction.complex.TimeSpanRestrictionItemEntity is mapped (with entity name TimeSpanRestrictionItem) as a joined subclass of the entity named RestrictionItem.
I have had a look at the Hibernate source for 3.3.2.ga and it looks like problem is the way that the org.hibernate.tuple.entity.EntityMetamodel is using it entityNameByInheritenceClassNameMap field:
* Puts to the map are based on PersistentClass.getMappedClass() as a key - a Class object
* Gets from the map (in findEntityNameByEntityClass method) are using the class name
Presumably (given the name of the map field) both put and get should be using the class name.
--
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
14 years, 4 months
[Hibernate-JIRA] Created: (HHH-3045) Duplicated column aliases in scalar query
by Anderson Souza (JIRA)
Duplicated column aliases in scalar query
-----------------------------------------
Key: HHH-3045
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3045
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: Hibernate 3.2.4SP1, 3.2.5GA
Oracle 10g
Reporter: Anderson Souza
Priority: Critical
Attachments: ddl-tables.sql, dominio.zip
The HQL bellow works fine, but when I add a call to a funcion in the select clause the SQL generated has duplicated aliases and it generate error on query execution, because the query is paginated.
{code}
select a
from Area a
inner join fetch a.horarioPadrao
left outer join fetch a.horarioTemporario as hrtemp
{code}
The SQL generated for this query is:
{code}
select * from (
select area0_.cod_local as cod1_15_0_,
horarioare1_.cod_area as cod1_6_1_,
horarioare2_.cod_area as cod1_7_2_,
area0_.des_local as des2_15_0_,
area0_.sig_local as sig3_15_0_,
area0_.flg_extinto as flg4_15_0_,
horarioare1_.hr_hora_ini as hr2_6_1_,
horarioare1_.hr_hora_fim as hr3_6_1_,
horarioare1_.flg_fim_semana as flg4_6_1_,
horarioare2_.hr_hora_ini as hr2_7_2_,
horarioare2_.hr_hora_fim as hr3_7_2_,
horarioare2_.flg_fim_semana as flg4_7_2_,
horarioare2_.dat_ini_vigencia as dat5_7_2_,
horarioare2_.dat_fim_vigencia as dat6_7_2_
from esq_fp.tb_local area0_
inner join tb_horario_local_padrao horarioare1_ on area0_.cod_local=horarioare1_.cod_area
left outer join tb_horario_local_temporario horarioare2_ on area0_.cod_local=horarioare2_.cod_area
where 1=1
order by area0_.sig_local )
where rownum <= ?
{code}
The scalar HQL query that generate duplicated column names is:
{code}
select a, count(*)
from Area a
inner join fetch a.horarioPadrao
left outer join fetch a.horarioTemporario as hrtemp
{code}
The SQL generated is:
{code}
select * from (
select area0_.cod_local as col_0_0_,
count(*) as col_1_0_,
horarioare1_.cod_area as cod1_6_1_,
horarioare2_.cod_area as cod1_7_2_,
area0_.cod_local as cod1_15_0_,
horarioare1_.cod_area as cod1_6_1_,
horarioare2_.cod_area as cod1_7_2_,
area0_.des_local as des2_15_0_,
area0_.sig_local as sig3_15_0_,
area0_.flg_extinto as flg4_15_0_,
horarioare1_.hr_hora_ini as hr2_6_1_,
horarioare1_.hr_hora_fim as hr3_6_1_,
horarioare1_.flg_fim_semana as flg4_6_1_,
horarioare2_.hr_hora_ini as hr2_7_2_,
horarioare2_.hr_hora_fim as hr3_7_2_,
horarioare2_.flg_fim_semana as flg4_7_2_,
horarioare2_.dat_ini_vigencia as dat5_7_2_,
horarioare2_.dat_fim_vigencia as dat6_7_2_
from esq_fp.tb_local area0_
inner join tb_horario_local_padrao horarioare1_ on area0_.cod_local=horarioare1_.cod_area
left outer join tb_horario_local_temporario horarioare2_ on area0_.cod_local=horarioare2_.cod_area
where 1=1
order by area0_.sig_local )
where rownum <= ?
{code}
As you can see the aliases cod1_6_1_ and cod1_7_2_ are repeated and this repetition breaks the paginated query, beacause the main query appears in the from clause.
The HBM's and classes are attached.
--
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
14 years, 4 months
[Hibernate-JIRA] Created: (HHH-3058) When using native sql query and multiple selects with setMaxResults, Hibernate inserts the TOP statement in the first query
by Sean Blaes (JIRA)
When using native sql query and multiple selects with setMaxResults, Hibernate inserts the TOP statement in the first query
---------------------------------------------------------------------------------------------------------------------------
Key: HHH-3058
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3058
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.4.sp1
Environment: Hibernate 3.2.4sp1, Microsoft SQL Server
Reporter: Sean Blaes
Priority: Minor
When using a query similar to the following:
DECLARE @SUB_TABLE TABLE(
ID INT
)
INSERT INTO @SUB_TABLE
SELECT ID
FROM FOO
SELECT *
FROM BAR
INNER JOIN @SUB_TABLE
ON ...
Then if I call setMaxResults(100) on the query object. It inserts "TOP 100" in the first query, which isn't really what would be expected. Since the second SELECT actually consists of the data that will be returned, the TOP 100 statement should go there.
I'd expect it's an easy fix. Just start your search for SELECT from the bottom rather than the top. However, I guess you have to make sure you're not hitting a subquery of a larger select either... I may try cooking up a patch this weekend for this if I can find the time, and I'll attach it to this issue if I do.
--
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
14 years, 5 months