[Hibernate-JIRA] Updated: (HHH-817) Aggregate projection aliases should not be applied to where-clause
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Diego Pires Plentz updated HHH-817:
-----------------------------------
Summary: Aggregate projection aliases should not be applied to where-clause (was: using projections is causing SQL query error on oracle (ORA-00904 error))
Component/s: core
> 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, 3 months
[Hibernate-JIRA] Created: (HHH-2681) Aggregate projection aliases should not be applied to where-clause
by Dmitry Katsubo (JIRA)
Aggregate projection aliases should not be applied to where-clause
------------------------------------------------------------------
Key: HHH-2681
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2681
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1
Reporter: Dmitry Katsubo
Priority: Minor
Please, have a look at the following expression:
Criteria criteria = session.createCriteria(ClauseStatisticsImpl.class);
criteria.setProjection(
Projections.projectionList()
.add(Projections.groupProperty("clause"), "clause")
.add(Projections.max("useDate"), "useDate"))
.add(Property.forName("useDate").eq("2007-12-12"));
criteria.addOrder(Order.desc("useDate")).setMaxResults(20).list();
The problem is that the "eq" expression is applied to groupped property. This is not correct and causes SQL exception. Aliases defined for aggregate projections, should be only allied to "group", "having" and "order" clauses.
The mapping is:
<class name="ClauseStatisticsImpl" table="stc_clause_statistics">
<cache usage="read-write"/>
<composite-id>
<key-many-to-one name="clause" column="clauseId" class="ClauseImpl"/>
<key-property name="useDate"/>
</composite-id>
</class>
The error is:
12:32.22 [ERROR] org.hibernate.util.JDBCExceptionReporter - Column not found: Y1_ in statement [select top ? this_.clauseId as y0_, max(this_.useDate) as y1_ from stc_clause_statistics this_ where this_.userId=? and y1_=? group by this_.clauseId order by y1_ desc]
Exception in thread "AWT-EventQueue-0" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
... 27 more
Caused by: java.sql.SQLException: Column not found: Y1_ in statement [select top ? this_.clauseId as y0_, max(this_.useDate) as y1_ from stc_clause_statistics this_ where this_.userId=? and y1_=? and this_.clauseId in (select this0__.id as y0_ from stc_clause this0__ where this0__.userId in (?, ?) and this0__.languageName=? and this0__.procedureName=? and this0__.phaseName=?) group by this_.clauseId order by y1_ desc]
at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 34 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
18 years, 3 months
[Hibernate-JIRA] Created: (HHH-2490) ClassCastException causes a logging statement to throw another ClassCastException upon inconsistent instantiation of NullableType
by Øyvind Roth (JIRA)
ClassCastException causes a logging statement to throw another ClassCastException upon inconsistent instantiation of NullableType
---------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2490
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2490
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: MS SQLServer
Windows 2000
Java 1.5.0_10
Reporter: Øyvind Roth
(Have me excused that I don't know well the internalities of Hibernate,
but I think that you get the point from some kind of "bird's perpective" anyhow).
My pojo is defined in my xml mapping with a column/field as follows:
...
<property name="encrypted"
type="string"
column="encrypted"
insert="true"
update="true"
not-null="true"/>
...
The corresponding POJO class is defined with two access methods:
String getEncrypted();
and
boolean isEncrypted();
The field is a String with possible values "f" or "t".
Of convenience reasons I have added a parallell method
operating on boolean. My database is designed with a CHAR(1)
for booleans. (All this because the dam... RDBMS standard doesn't
advice a consistent boolean data type, a really big blunder from
time back in System R. OT ok, but I got it out.)
When Hibernate parses my instantiated pojo, a Boolean instance is
generated. But it's "repository" is prepared with a StringType as a
consequence of my XML configuration file. During the course, the
method nullSafeSet of class NullableType is called with the value
parameter Boolean. Eventually the
"public abstract String toString(Object value) throws HibernateException;"
method is called for StringType, which is implemented with a simple typecast.
Exception received. Whether this behavior is ok or not is one discussion.
But there's a second problem to it also: When the exception is received,
NullableType tries to log the event:
...
catch ( RuntimeException re ) {
log().info( "could not bind value '" + nullSafeToString( value ) + "' to parameter: " + index + "; " + re.getMessage() );
throw re;
}
...
And the same shit happens again. So the developer does not receive the actual exception,
but the exception received from the logging statement. A strong golden rule of thumb:
A logging statement should never ever throw. This is what I would call a bug in Hibernate.
Setting the log level to ERROR will of course not solve the problem,
because the string paramater is evaluated before the log statement is ever reached.
A variant of this issue is described under: "HHH-2034"
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2648) NPE in FromClause.java
by Heiko W. Rupp (JIRA)
NPE in FromClause.java
----------------------
Key: HHH-2648
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2648
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.1
Environment: JBoss 4.2, JDK 1.5
Reporter: Heiko W. Rupp
This JPA Query
query="SELECT m " +
"FROM MeasurementDataTrait AS m " +
"WHERE m.schedule.resource.id = :resourceId" +
" AND m.schedule.definition.displayType = :displayType " +
" AND m.id.timestamp = (" +
" SELECT MAX(mdt.id.timestamp) " +
" FROM MeasurementDataTrait AS mdt" +
" WHERE m.scheduleId = mdt.scheduleId" +
" )" +
" GROUP BY m " +
" ORDER BY m.id.timestamp DESC"
Results in this NPE:
java.lang.NullPointerException
at org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements(FromClause.java:120)
at org.hibernate.hql.ast.tree.FromClause.getFromElement(FromClause.java:107)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:81)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4049)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3528)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
When I remove the subselect, then the query gets parsed nicely.
--
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, 3 months
[Hibernate-JIRA] Updated: (HHH-1012) Index not created by SchemaUpdate
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1012?page=c... ]
Diego Pires Plentz updated HHH-1012:
------------------------------------
Affects Version/s: (was: 3.1 beta 2)
(was: 3.1 beta 1)
(was: 3.0.5)
3.2.5
Issue Type: Improvement (was: Bug)
Summary: Index not created by SchemaUpdate (was: index not created by SchemaUpdate)
Component/s: metamodel
> Index not created by SchemaUpdate
> ---------------------------------
>
> Key: HHH-1012
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1012
> Project: Hibernate3
> Issue Type: Improvement
> Components: metamodel
> Affects Versions: 3.2.5
> Environment: Windows XP, MySQL/PostgreSQL
> Reporter: Xavier Farret
> Priority: Minor
> Attachments: Indexes.patch
>
>
> i'm using an hbm.xml as describe below and the 'hibernate.hbm2ddl.auto' is egal to update.
> <class table="featurestat" name=".....">
> <id name="id" type="long" column="idFeatureStat">
> <generator class="increment"/>
> </id>
> <properties name="fsUniqueValue" unique="true">
> ....
> </properties>
> <property name="frequency" .../>
> <property name="idFatherFeature" index="FeatStatDocExtSectFeat" not-null="true" type="long" column="..."/>
> ....
> </class>
> Indexes for pk or unique key are well created, but the index explicity named 'FeatStatDocExtSectFeat' is never created. If i put the property 'hibernate.hbm2ddl.auto' in the cfg.xml as 'create' the index is created. But in my case i have to set my property 'hibernate.hbm2ddl.auto' to update.
--
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, 3 months
[Hibernate-JIRA] Commented: (HHH-442) hibernate does not handle correctly covariant return types of java 1.5.
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-442?page=co... ]
Diego Pires Plentz commented on HHH-442:
----------------------------------------
Ramnivas Laddad, open another issue(and attach a running test case), cause I think that you problem is another. Btw, "Person implements Entity", don't "extends" ;-)
> hibernate does not handle correctly covariant return types of java 1.5.
> -----------------------------------------------------------------------
>
> Key: HHH-442
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-442
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.0.2
> Environment: INFO: Hibernate 3.0.2
> Windows XP Pro
> java version "1.5.0_03"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
> Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
> Reporter: Stefan Bühlmann
> Priority: Minor
> Attachments: covariant_problem.zip
>
>
> Hi Gavin,
> It seems as if hibernate does not handle correctly covariant return types of java 1.5.
> In the example included LocalWorkspace implements LocalWorkspaceI.
> The attribute visibleCommittedTrx and it's setters and getters use the type Transaction;
> But the interface LocalWorkspaceI uses TransactionI as a return type for getVisibleCommittedTrx().
> To put it the other way around, LocalWorkspace.getVisibleCommittedTrx() returns a class and not an interface, but this still implements the interface, since it is a covariant return type.
> It compiles nicely with java 1.5, but when run it get the following:
> org.hibernate.MappingException: An association from the table LOCALWORKSPACE refers to an unmapped class: x2.elements.interfaces.TransactionI
> This clearly shows, that hibernate tries to use TransactionI. But I never made a mapping for an interface!
> To use the stripped down example, just edit go.bat and set JAVA_HOME to your liking. Then run go.bat.
> But how can I upload a zip?
> Bye Stefan
--
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, 3 months
[Hibernate-JIRA] Deleted: (HSEARCH-120) Tz4r was here
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-120?pag... ]
Emmanuel Bernard deleted HSEARCH-120:
-------------------------------------
> Tz4r was here
> -------------
>
> Key: HSEARCH-120
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-120
> Project: Hibernate Search
> Issue Type: Bug
> Environment: Tz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was here
> Reporter: tzr333
>
> Tz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was hereTz4r was here
--
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, 3 months