[Hibernate-JIRA] Commented: (HHH-1689) unexpected AST node: query -- CASE WHEN THEN subquery
by Anupam M (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1689?page=c... ]
Anupam M commented on HHH-1689:
-------------------------------
The following portion is giving error:
if the internal query is replaced by static data , the query works fine.
case when p.lastValue in (select st.statusId from StatusType st where st.indicator = 'RED') then 'RED' else 'GREEN' end)
> unexpected AST node: query -- CASE WHEN THEN subquery
> -----------------------------------------------------
>
> Key: HHH-1689
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1689
> Project: Hibernate3
> Issue Type: Bug
> Components: query-sql
> Environment: Hibernate 3.x
> Oracle 9.2.0
> Reporter: Alejandro Torras
> Original Estimate: 2 days, 4 hours
> Remaining Estimate: 2 days, 4 hours
>
> Hello,
> I got a <<org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: query [ >> exception with the following query:
> FROM
> t1 AS vo,
> t2 AS vo2
> WHERE vo2.indIdiomaSistema = 'S'
> AND vo.id.codiIdioma.id = :id_codiIdioma_id
> GROUP BY vo.id.codiTipusIdent.id
> HAVING COUNT(*) BETWEEN
> CASE :estat
> WHEN '1' THEN (SELECT COUNT(*) FROM t2 WHERE ind_idioma_sistema = 'S')
> ELSE 0 END
> AND 4
> ORDER BY vo.nomTipusIdent asc
> It seems that the THEN clause doesn't expect a query that Oracle 9.2 handles properly.
> Regards,
> Alejandro Torras.
--
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
18 years, 4 months
[Hibernate-JIRA] Created: (HHH-3009) Bug in dirty checking of Entities with char[]
by Michael Plöd (JIRA)
Bug in dirty checking of Entities with char[]
---------------------------------------------
Key: HHH-3009
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3009
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Environment: Hibernate 3.2.3 Oracle 10g
Reporter: Michael Plöd
I guess that I found a bug in the dirty checking of properties of type char[]. Every entity containing a property of type char[] will be treated as a dirty one.
The reason for this is that neither the CharacterArrayType nor the AbstractCharArrayType override the isDirty Method. This means that the isDirty method of AbstractType will be used. Unfortunately this method finally calls (through isSame, isEqual) EqualsHelper.equals(x, y) which would compare the char[] like this:
public static boolean equals(Object x, Object y) {
return x==y || ( x!=null && y!=null && x.equals(y) );
}
This results in every char[] to be treated dirty since char[] can't implement equals().
In my opinion this behavior is wrong. I think that the AbstractCharArrayType should have an isDirty method which performs an equals check through Arrays.equals(...).
If needed I can provide a test case and a bug fix for this!
Cheers,
Mike
--
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
18 years, 4 months
[Hibernate-JIRA] Commented: (HHH-817) Aggregate projection aliases should not be applied to where-clause
by Jose Luis Piedrahita (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Jose Luis Piedrahita commented on HHH-817:
------------------------------------------
This bug must be marked as critical, if not, what is the reason for not doing it? maybe the "this. prefix in where"? this works for me but not to others.
Please we need a answer.
> Aggregate projection aliases should not be applied to where-clause
> ------------------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5
> Environment: Oracle 9.2.0.6, Hibernate 3.0.5, Spring Framework 1.2.2 based application working on Jakarta Tomcat 5.0.28
> Reporter: Michal Jastak
> Priority: Minor
> Attachments: HHH-817.patch
>
>
> following java code:
> protected Entity loadEntityLightweight(Serializable entityId) throws DataAccessException {
> Criteria criteria = getSession().createCriteria(Entity.class);
> ProjectionList projectionList = Projections.projectionList();
> projectionList.add(Property.forName(BaseEntity.PROP_ID), BaseEntity.PROP_ID);
> projectionList.add(Property.forName(BaseEntity.PROP_TYPE), BaseEntity.PROP_TYPE);
> criteria.setProjection(projectionList);
> criteria.add(Restrictions.eq(BaseEntity.PROP_ID, entityId));
> criteria.setResultTransformer(new AliasToBeanResultTransformer(Entity.class));
> return (Entity) criteria.uniqueResult();
> }
> generates following SQL query:
> select this_.id as y0_, this_.type as y1_ from entities this_ left outer join facilities this_1_ on this_.id=this_1_.id left outer join users this_2_ on this_.id=this_2_.id left outer join addresses address2_ on this_.address_id=address2_.id left outer join entities entity3_ on this_2_.employer_id=entity3_.id left outer join facilities entity3_1_ on entity3_.id=entity3_1_.id left outer join users entity3_2_ on entity3_.id=entity3_2_.id where y0_=?
> y0_ = ? expression in where clause is causing a 904 error on Oracle 9:
> ORA-00904: "Y0_": invalid identifier
> hibernate dialect: org.hibernate.dialect.Oracle9Dialect
> mapping for Entity class:
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping default-lazy="false" default-cascade="save-update">
>
> <class name="Entity" table="entities" mutable="true">
> <id name="id" type="java.lang.Long" unsaved-value="null">
> <generator class="sequence">
> <param name="sequence">entities_id_seq</param>
> </generator>
> </id>
> <many-to-one name="address" class="Address" column="address_id" />
> ...
> <!--
> - Facilities
> -->
> <joined-subclass name="Facility" table="facilities">
> <key column="id" />
> ...
> <set name="users" inverse="true" lazy="true">
> <key column="facility_id" />
> <one-to-many class="User" />
> </set>
> </joined-subclass>
> <!--
> - Users
> -->
> <joined-subclass name="User" table="users" dynamic-insert="true" dynamic-update="true">
> <key column="id" />
> <many-to-one name="employer" class="Entity" column="employer_id" cascade="none" />
> ...
> <set name="userAuthorities" inverse="true" cascade="all-delete-orphan">
> <key column="user_id" />
> <one-to-many class="Authority" />
> </set>
> </joined-subclass>
> </class>
> </hibernate-mapping>
--
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
18 years, 4 months
[Hibernate-JIRA] Created: (HHH-2991) Non public constructors cannot be used whith 'select new Object(...)' in HQL
by Jaime Porras (JIRA)
Non public constructors cannot be used whith 'select new Object(...)' in HQL
----------------------------------------------------------------------------
Key: HHH-2991
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2991
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5
Reporter: Jaime Porras
Priority: Minor
Attachments: ReflectHelper.java
Using following HQL
<query name="family">
<![CDATA[
select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
]]>
</query>
with
public class Family {
protected Family(String mother, String mate, String offspr) {
// code
}
}
Note: assuming Family constructor is correct (argument types are correct)
During hql analyzing process, Hibernate produces the following error:
SEVERE: Error in named query: family
org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [Family] [
select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
]
This error is produced because Family constructor is protected (may be private).
org.hibernate.util.ReflectHelper is the class used to find the appropriate constructor. But the code used to do it calls clazz.getConstructors(), getting only the public contructors:
public static Constructor getConstructor(Class clazz, Type[] types) throws PropertyNotFoundException {
final Constructor[] candidates = clazz.getDeclaredConstructors(); // Get all constructors (public and not public)
for ( int i=0; i<candidates.length; i++ ) {
final Constructor constructor = candidates[i];
final Class[] params = constructor.getParameterTypes();
if ( params.length==types.length ) {
boolean found = true;
for ( int j=0; j<params.length; j++ ) {
final boolean ok = params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
types[j] instanceof PrimitiveType &&
params[j] == ( (PrimitiveType) types[j] ).getPrimitiveClass()
);
if (!ok) {
found = false;
break;
}
}
if (found) {
if ( !isPublic(clazz, constructor) ) constructor.setAccessible(true);
return constructor;
}
}
}
throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}
The only thing to do is change the first line by:
final Constructor[] candidates = clazz.getDeclaredConstructors();
PD:
If only public constructors will be used the this code has no sense:
if (found) {
if ( !isPublic(clazz, constructor) ) constructor.setAccessible(true);
return constructor;
}
--
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
18 years, 4 months