[Hibernate-JIRA] Created: (HHH-3631) HQL grammar does not actually support the CASE statement
by Andra Nedelcovici (JIRA)
HQL grammar does not actually support the CASE statement
--------------------------------------------------------
Key: HHH-3631
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3631
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1 ga, Postgresql
Reporter: Andra Nedelcovici
Using a simple form of the CASE statement in HQL like the following
from EnumerationValue where enumeration = 'XXX' and (case :param
when 1 then value > 5
when 2 then value < 100
else true
end) order by id
yields
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: case near line 1, column 54 [...]
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 also tried this (silly, isn't it?):
from EnumerationValue where enumeration = 'XXX' and (1=1 and case 3
when 1 then false
when 2 then true
else true
end) order by id
in order to check for HQL grammar limitations, but the result is just the same.
I should also mention that I ran successfully the above queries in a PostgreSQL console (with the normal adjustments).
--
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
[Hibernate-JIRA] Commented: (HHH-1400) Using formula-based property causes invalid SQL code for children "subselect" query
by Florian Rock (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400?page=c... ]
Florian Rock commented on HHH-1400:
-----------------------------------
pls try my little ugly "fix"... it worked for me =)
> Using formula-based property causes invalid SQL code for children "subselect" query
> -----------------------------------------------------------------------------------
>
> Key: HHH-1400
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 rc3
> Environment: Hibernate 3.0.5, Hibernate 3.1rc3
> Oracle 8i
> Reporter: Chris Rogers
> Attachments: SubselectFetch.java, subselectformula.zip, SubselectFormulaBug.zip
>
>
> I have simple one-to-many relationship, mapped as set:
> <class name="Parent">
> <set name="children" lazy="false" fetch="subselect">
> <key column="PARENT_OID"/>
> <one-to-many class="Child"/>
> </set>
> </class>
> this works fine, constructing subselect SQL which looks like (e.g. for HQL query "from Parent"):
> select <child fields> from <child table> where child.PARENT_OID in (select this_.OID from PARENT this_)
> (simplified)
> However, when adding a formula-based property into Parent:
> <property name="myFormulaField" formula="(complex_select )"/>
> Now SQL becomes:
> select <child fields> from <child table> where PARENT_OID in (complex_select) as formula0_1_, <some parent fields> from PARENT this_)
> This SQL fails because of incorrect grammar (it also seems that backet is missing).
> This is something weird, because subselect fetching only needs Parent's identity column, not any other properties. And I don't think it should be affected by Parent's formula-based properties.
> I can provide more details if necessary, I stripped out all extra mapping/SQL stuff because it seems to be irrelevant here.
> This bug appeared in 3.0.5 later I've downloaded 3.1rc3 and it also fails.
--
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
[Hibernate-JIRA] Created: (ANN-789) ParameterizedType.setParameterValues method is getting null
by Maxim Petrashev (JIRA)
ParameterizedType.setParameterValues method is getting null
-----------------------------------------------------------
Key: ANN-789
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-789
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.GA
Reporter: Maxim Petrashev
Entity class has enum property that is annotated by custom user type. This UserType implementation class implements also ParameterizedType interface.
SimpleValueBinder evaluates parameters for enum perfectly in block:
if ( BinderHelper.ANNOTATION_STRING_DEFAULT.equals( type ) ) {
if ( returnedClassOrElement.isEnum() ) {
that starts on line 160 but when setType calls setExplicitType method on line 191 last one clear typeParameters:
line 202: typeParameters.clear();
and fillSimpleValue method path nothing to simpleValue. Last one (in this case) pass null to ParameterizedType.setParameterValues method. I believe it should pass properties that were initialized in
if ( BinderHelper.ANNOTATION_STRING_DEFAULT.equals( type ) ) {
if ( returnedClassOrElement.isEnum() ) {
block (as EnumType is receiving)
--
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
[Hibernate-JIRA] Commented: (HHH-1400) Using formula-based property causes invalid SQL code for children "subselect" query
by kishorekpotta (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400?page=c... ]
kishorekpotta commented on HHH-1400:
------------------------------------
select territoryp0_.TERR_PRICE_CAT_ID as TERR12_1_, territoryp0_.TERRITORY_ID as TERRITORY1_1_, from ETRANS.DMD_TERR_PRICE_CATEGORY_DIM territoryp0_ where territoryp0_.TERR_PRICE_CAT_ID in (select this_.TERR_PRICE_CAT_ID from dmd.dmd_territory_cluster dtc where dtc.PARENT_TERRITORY_ID = territory2_.TERRITORY_ID and dtc.CHILD_TERRITORY_ID = 1) as formula11_0_ from ETRANS.DMD_TERRITORY_PRICE_CATEGORY this_ left outer join DMD.DMD_Territory territory2_ on this_.TERRITORY_ID=territory2_.TERRITORY_ID where this_.PRICE_CATEGORY_ID=? and this_.TERRITORY_ID<>? )
23:39:01,807 WARN [JDBCExceptionReporter] SQL Error: 933, SQLState: 42000
23:39:01,807 ERROR [JDBCExceptionReporter] ORA-00933: SQL command not properly ended
Below is my forumla query.
formula=(select distinct 'Y' from dmd.dmd_territory_cluster dtc
where dtc.PARENT_TERRITORY_ID = TERRITORY_ID
and dtc.CHILD_TERRITORY_ID = 1)"
> Using formula-based property causes invalid SQL code for children "subselect" query
> -----------------------------------------------------------------------------------
>
> Key: HHH-1400
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 rc3
> Environment: Hibernate 3.0.5, Hibernate 3.1rc3
> Oracle 8i
> Reporter: Chris Rogers
> Attachments: SubselectFetch.java, subselectformula.zip, SubselectFormulaBug.zip
>
>
> I have simple one-to-many relationship, mapped as set:
> <class name="Parent">
> <set name="children" lazy="false" fetch="subselect">
> <key column="PARENT_OID"/>
> <one-to-many class="Child"/>
> </set>
> </class>
> this works fine, constructing subselect SQL which looks like (e.g. for HQL query "from Parent"):
> select <child fields> from <child table> where child.PARENT_OID in (select this_.OID from PARENT this_)
> (simplified)
> However, when adding a formula-based property into Parent:
> <property name="myFormulaField" formula="(complex_select )"/>
> Now SQL becomes:
> select <child fields> from <child table> where PARENT_OID in (complex_select) as formula0_1_, <some parent fields> from PARENT this_)
> This SQL fails because of incorrect grammar (it also seems that backet is missing).
> This is something weird, because subselect fetching only needs Parent's identity column, not any other properties. And I don't think it should be affected by Parent's formula-based properties.
> I can provide more details if necessary, I stripped out all extra mapping/SQL stuff because it seems to be irrelevant here.
> This bug appeared in 3.0.5 later I've downloaded 3.1rc3 and it also fails.
--
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
[Hibernate-JIRA] Commented: (HHH-1400) Using formula-based property causes invalid SQL code for children "subselect" query
by kishorekpotta (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400?page=c... ]
kishorekpotta commented on HHH-1400:
------------------------------------
was this issue resolved? I am still facing this issue. when used formaula property along with fetch="subslect", I am getting invalid query error.
> Using formula-based property causes invalid SQL code for children "subselect" query
> -----------------------------------------------------------------------------------
>
> Key: HHH-1400
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 rc3
> Environment: Hibernate 3.0.5, Hibernate 3.1rc3
> Oracle 8i
> Reporter: Chris Rogers
> Attachments: SubselectFetch.java, subselectformula.zip, SubselectFormulaBug.zip
>
>
> I have simple one-to-many relationship, mapped as set:
> <class name="Parent">
> <set name="children" lazy="false" fetch="subselect">
> <key column="PARENT_OID"/>
> <one-to-many class="Child"/>
> </set>
> </class>
> this works fine, constructing subselect SQL which looks like (e.g. for HQL query "from Parent"):
> select <child fields> from <child table> where child.PARENT_OID in (select this_.OID from PARENT this_)
> (simplified)
> However, when adding a formula-based property into Parent:
> <property name="myFormulaField" formula="(complex_select )"/>
> Now SQL becomes:
> select <child fields> from <child table> where PARENT_OID in (complex_select) as formula0_1_, <some parent fields> from PARENT this_)
> This SQL fails because of incorrect grammar (it also seems that backet is missing).
> This is something weird, because subselect fetching only needs Parent's identity column, not any other properties. And I don't think it should be affected by Parent's formula-based properties.
> I can provide more details if necessary, I stripped out all extra mapping/SQL stuff because it seems to be irrelevant here.
> This bug appeared in 3.0.5 later I've downloaded 3.1rc3 and it also fails.
--
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
[Hibernate-JIRA] Resolved: (HBX-524) Reverse of one-to-one relationships
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-524?page=co... ]
Max Rydahl Andersen resolved HBX-524.
-------------------------------------
Resolution: Fixed
fixed for now.
JPA generation generates hibernate specific annotation for the key generator though.
Would be nice if that could be a supported JPA ?
> Reverse of one-to-one relationships
> -----------------------------------
>
> Key: HBX-524
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-524
> Project: Hibernate Tools
> Issue Type: Bug
> Components: reverse-engineer
> Affects Versions: 3.1beta2
> Environment: HIbernate 3.1, Oracle 9i
> Reporter: Andrea Cattani
> Assignee: Anthony Patricio
> Fix For: 3.2.4.CR1
>
> Attachments: HBX-524.patch, HBX-524v2.patch, jpa-generation-patch.patch, one-to-one-marcio.patch, patch.txt
>
>
> Hi,
> I've posted this issue to the forum and got this response from Max, Hibernate Team:
> "the reveng tools does not detect this as a one-to-one. it probably could, so add a request/patch to jira."
> The problem I've faced is the following:
> I have two tables, let's say
> - table A with column ID (PK) and other fields
> - table B with column ID (PK) and other fields
> table B has a foreign key constraint against table A, from column ID to column ID (one-to-one)
> When I reverese the tables with the HibernateTools I have such a resultant mapping for table B:
> <class name="B" table="B" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned" />
> </id>
> <[b]many-to-one name[/b]="a" class="A" update="false" insert="false" fetch="select">
> <column name="ID" length="12" not-null="true" unique="true" />
> </many-to-one>
> ....
> And this one for table A:
> <class name="A" table="A" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned"/>
> </id>
> <set name="b" inverse="true">
> <key>
> <column name="ID" length="12" not-null="true" unique="true" />
> </key>
> <[b]one-to-many[/b] class="B" />
> </set>
> </class>
> while I was expecting something like:
> [i]<one-to-one name="a" class="A" constrained="true"/>[/i]
> in table B, and the same (or nothing) in table A
> Thank you
> Andi
--
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
[Hibernate-JIRA] Created: (EJB-365) Can't execute query
by Radosław Smogura (JIRA)
Can't execute query
-------------------
Key: EJB-365
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-365
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.3.2.GA
Environment: Hibernate 3.2.6
PostrgreSQL 8.0.13
Glassfish
Reporter: Radosław Smogura
Priority: Critical
Execution followed named query with followed entity
@Entity
@NamedQuery(name="Foo.test",
query="SELECT f FROM Foo f WHERE ((:bool IS NULL) OR (f.bool = :bool)) ")
public class Foo implements Serializable{
@Id
int id;
boolean bool;
public boolean isBool() {
return bool;
}
public void setBool(boolean bool) {
this.bool = bool;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
and parameter bool = null
causes PostgreSQL error ERROR: operator does not exist: boolean = bytea
--
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