[Hibernate-JIRA] Commented: (HHH-817) Projection aliases should not be applied to where-clause (Milosz Tylenda)
by Taylor Mathewson (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Taylor Mathewson commented on HHH-817:
--------------------------------------
Thank you Gail!!
> Projection aliases should not be applied to where-clause (Milosz Tylenda)
> -------------------------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.5.5, 3.6.0.Beta3
> 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
> Assignee: Gail Badner
> Fix For: 3.6.0.Beta4
>
> Attachments: HHH-817.patch, HHH-817_3.3.2GA_17882.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
14 years, 5 months
[Hibernate-JIRA] Resolved: (HHH-817) Projection aliases should not be applied to where-clause (Milosz Tylenda)
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Gail Badner resolved HHH-817.
-----------------------------
Resolution: Fixed
> Projection aliases should not be applied to where-clause (Milosz Tylenda)
> -------------------------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.5.5, 3.6.0.Beta3
> 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
> Assignee: Gail Badner
> Fix For: 3.6.0.Beta4
>
> Attachments: HHH-817.patch, HHH-817_3.3.2GA_17882.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
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-5514) Add ability to lock / reattach an entity with a dirty collection
by Steve McIntyre (JIRA)
Add ability to lock / reattach an entity with a dirty collection
----------------------------------------------------------------
Key: HHH-5514
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5514
Project: Hibernate Core
Issue Type: New Feature
Components: core
Environment: 3.3.2.GA, Oracle 10g
Reporter: Steve McIntyre
We are using Hibernate 3.3.2.GA, with optimistic locking via @Version and the session per request pattern (and thus detached entity object graphs).
We have a very complex object graph consisting of carts, orders, line items, sub line items, payments, delivery, sub line item deliveries, etc. In most situations, our cart executes against a single order. However, there are cases where multiple orders can be involved. Our orders can be fairly large in terms of the number of line items, sub items, etc. As a result, as users navigate the application we only load the orders they request.
The issue gets more complex if two orders (e.g. order #1 and #2) are involved in multiple carts. Why? Some entities in the object graph (e.g. carts, payments, deliveries, etc) can span orders and transactions. Consider a multiple-step/session cart where we load order #1, associate it with a new cart and detach the object graph. The user subsequently requests elements from order #2 be loaded into the new cart. So, we load order #2, associate it with the same/new cart and detach the object graph.
Now, if in a previous cart/transaction, orders #1 and #2 shared a (eg) delivery, when we load #2 and its associated delivery, in order to avoid two instances of this same delivery in our detached object graph, we need to re-attach the previously loaded delivery to the new session, prior to loading order #2.
Since we are not ready to persist changes to the database yet, and because this delivery may be dirty, we choose to use Hibernate's "lock" API (as opposed to refresh, load, merge, update, etc) to re-attach the delivery in our graph to the current session.
All this works great except that if our delivery entity has a pesisted collection that has been modified, a "reassociated object has dirty collection" Hibernate exception is thrown.
We could work around this situation by adding a new collection to our delivery entity that maintained changes to the pesisted collection, then just prior to calling "merge" we could move the changes to the persistence collection. However, as I mentioned we have a complex object graph... that involves 10 entities with a total of 23 persisted collections we'd have to manage this way for this one aspect of our system.
As an experiment, I commented out one line in the org.hibernate.event.def.OnLockVisitor class, processCollection method (below) to no longer throw the exception.
{noformat}
if ( persistentCollection.isDirty() ) {
// Don't throw exception hack
// throw new HibernateException( "reassociated object has dirty collection" );
}
reattachCollection( persistentCollection, type );
{noformat}
and returned early from org.hibernate.event.def.DefaultLockEventListener class, onLock method (below)
{noformat}
if ( !ForeignKeys.isNotTransient( event.getEntityName(), entity, Boolean.FALSE, source ) ) {
return; // Return early hack
// throw new TransientObjectException(
// "cannot lock an unsaved transient instance: " +
// persister.getEntityName()
// );
}
{noformat}
With these two changes, I was able to lock / re-attach all the necessary entities in our detached object graph, and subsequently was able to merge the entire graph successfully.
My questions to the Hibernate team are:
1) Is there already existing functionality that could achieve the same results (e.g. re-attach detached entities that contain dirty persistence collections to a new session )?
2) Would they consider adding another org.hibernate.LockMode type (e.g. DIRTY) that would support the behavior I've described above? If so on this latter option, I would be happy to work on the code fix to support the DIRTY or maybe DIRTY_COLLECTION lock mode.
--
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
[Hibernate-JIRA] Commented: (HHH-817) Projection aliases should not be applied to where-clause (Milosz Tylenda)
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Gail Badner commented on HHH-817:
---------------------------------
Milosz, thanks for your patch!
I decided to go with a separate method (CriteriaQuery.findColumns(String propertyName, Criteria subcriteria )) instead of adding a flag to getColumnsUsingProjection(...) to clarify that projection aliases are not used by restrictions in the where clause.
The fix is checked into trunk.
> Projection aliases should not be applied to where-clause (Milosz Tylenda)
> -------------------------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.5.5, 3.6.0.Beta3
> 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
> Assignee: Gail Badner
> Fix For: 3.6.0.Beta4
>
> Attachments: HHH-817.patch, HHH-817_3.3.2GA_17882.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
14 years, 5 months
[Hibernate-JIRA] Updated: (HHH-817) Projection aliases should not be applied to where-clause (Milosz Tylenda)
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Gail Badner updated HHH-817:
----------------------------
Summary: Projection aliases should not be applied to where-clause (Milosz Tylenda) (was: Projection aliases should not be applied to where-clause)
> Projection aliases should not be applied to where-clause (Milosz Tylenda)
> -------------------------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.5.5, 3.6.0.Beta3
> 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
> Assignee: Gail Badner
> Fix For: 3.6.0.Beta4
>
> Attachments: HHH-817.patch, HHH-817_3.3.2GA_17882.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
14 years, 5 months
[Hibernate-JIRA] Updated: (HHH-817) Projection aliases should not be applied to where-clause
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Gail Badner updated HHH-817:
----------------------------
Priority: Major (was: Minor)
Affects Version/s: 3.5.5
3.6.0.Beta3
> Projection aliases should not be applied to where-clause
> --------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.5.5, 3.6.0.Beta3
> 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
> Assignee: Gail Badner
> Fix For: 3.6.0.Beta4
>
> Attachments: HHH-817.patch, HHH-817_3.3.2GA_17882.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
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-5020) java.sql.SQLException: ORA-00904: "Y6_": invalid identifier when performing search by criteria with columns aliases defined and with restriction defined
by Alexander (JIRA)
java.sql.SQLException: ORA-00904: "Y6_": invalid identifier when performing search by criteria with columns aliases defined and with restriction defined
--------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5020
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5020
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.5
Environment: Oracle 10g
Reporter: Alexander
Attachments: stacktrace.JPG
The exception is occured when I performs search by criteria like this
DetachedCriteria headerCrit = DetachedCriteria.forClass(LOSHeader.class);
ProjectionList prjList = Projections.projectionList();
prjList.add(Projections.groupProperty("channelId"),"channelId");
prjList.add(Projections.groupProperty("channel"),"channel");
prjList.add(Projections.groupProperty("subCategoryId"),"subCategoryId");
prjList.add(Projections.groupProperty("subCategory"),"subCategory");
prjList.add(Projections.groupProperty("bevCategoryId"),"bevCategoryId");
prjList.add(Projections.groupProperty("bevCategory"),"bevCategory");
prjList.add(Projections.groupProperty("accessFilter"),"accessFilter");
headerCrit.setProjection(prjList);
headerCrit.add(Restrictions.like("accessFilter","%,INTERNAL;%"));
headerCrit.setResultTransformer(Transformers.aliasToBean(LOSHeader.class));
List result = pipelineDAO.loadByCriteria(headerCrit, LOSHeader.class);
Criteria string:
DetachableCriteria(CriteriaImpl(com.ko.cokechannel.los.impl.entity.LOSHeader:this[][accessFilter like %,INTERNAL;%][channelId as channelId, channel as channel, subCategoryId as subCategoryId, subCategory as subCategory, bevCategoryId as bevCategoryId, bevCategory as bevCategory, accessFilter as accessFilter]))
The is list of projections:
[channelId as channelId, channel as channel, subCategoryId as subCategoryId, subCategory as subCategory, bevCategoryId as bevCategoryId, bevCategory as bevCategory, accessFilter as accessFilter]
Method execution stack trace (also the screenshot of stack trace is attached) :
CriteriaQueryTranslator.getWhereCondition()->
String sqlString = entry.getCriterion().toSqlString( entry.getCriteria(), this );
SimpleExpression.toSqlString() ->
CriteriaQueryTranslator.getColumnsUsingProjection(criteria, propertyName); // propertyName is "accessFilter"
ProjectionList.getColumnAliases(String alias, int loc){ // alias = "accessFilter"
....
String[] result = getProjection(i).getColumnAliases(alias, loc);
if (result!=null) return result;
.....
result is: [y6_] // Restriction for accessFilter property is mathced with the value from projection aliases, so [y6_] is returned for the WHERE condition
WHERE clause sql: y6_ like ?
The final sql looks like:
select this_.CHANNEL_ID as y0_, this_.CHANNEL_NM as y1_, this_.SUB_CATEGORY_ID as y2_, this_.SUB_CATEGORY_NM as y3_, this_.BEV_CATEGORY_ID as y4_, this_.BEV_CATEGORY_NM as y5_, this_.ACCESS_FILTER as y6_ from V_LOS_LIST this_
WHERE y6_ like ? <<<<<<< ---- THIS IS WRONG -
group by this_.CHANNEL_ID, this_.CHANNEL_NM, this_.SUB_CATEGORY_ID, this_.SUB_CATEGORY_NM, this_.BEV_CATEGORY_ID, this_.BEV_CATEGORY_NM, this_.ACCESS_FILTER
I think that the cause of this issue is the same as was mentioned in http://opensource.atlassian.com/projects/hibernate/browse/HHH-2847
To easy reproduce this issue just try to search by a criteria like this:
DetachedCriteria criteria = DetachedCriteria.forClass(Entity.class);
criteria.setProjection(Projections.groupProperty("propertyA"),"propertyA");
criteria.add(Restrictions.like("propertyA", "%"));
criteria.setResultTransformer(Transformers.aliasToBean(Entity.class));
Thank you,
Alex
--
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
[Hibernate-JIRA] Updated: (HHH-817) Projection aliases should not be applied to where-clause
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Gail Badner updated HHH-817:
----------------------------
Assignee: Gail Badner
Fix Version/s: 3.6.0.Beta4
Summary: Projection aliases should not be applied to where-clause (was: Aggregate projection aliases should not be applied to where-clause)
> Projection aliases should not be applied to where-clause
> --------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> 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
> Assignee: Gail Badner
> Priority: Minor
> Fix For: 3.6.0.Beta4
>
> Attachments: HHH-817.patch, HHH-817_3.3.2GA_17882.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
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-2691) Insert Into Select command outputs incorrect exception
by John Aylward (JIRA)
Insert Into Select command outputs incorrect exception
------------------------------------------------------
Key: HHH-2691
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2691
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1
Environment: Hibernate 3.2.4.sp1 with Annotations 3.3.0 And Validator 3.0.0
MySQL 5.0.42
Reporter: John Aylward
receive following exception:
org.hibernate.QueryException: number of select types did not match those for insert [INSERT INTO ProviderInvoiceLineItem (amount,billingAccount,circuit,description,invoice,type) SELECT pili.amount,pili.billingAccount,pili.circuit,pili.description,:newInvoice,pili.type) FROM com.cicat.bedrock.billing.model.ProviderInvoiceLineItem pili WHERE pili.invoice = :oldInvoice]
exception should be that token ')' is not excepected near "pili.type"
Should not have gotten as far as it did, should have blown up on parsing the HQL
--
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