[Hibernate-JIRA] Commented: (HHH-817) Aggregate 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 commented on HHH-817:
---------------------------------
Please attach a runnable test case (Java + mapping).
> 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
17 years
[Hibernate-JIRA] Created: (HHH-2652) character x character varying
by Frederico (JIRA)
character x character varying
-----------------------------
Key: HHH-2652
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2652
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Environment: Hibernate 3.2.4.sp1, Postgresql 8.1
Reporter: Frederico
My problem: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2641?page=c...
Solution:
change types of the primary key's to 'character varying'.
hibernate works in different way when the primary key's are character, in my problem this happens:
12:21:43,427 DEBUG CollectionLoadContext:262 - 2 collections were found in result set for role: entidades.bdufop.Sistema.aplicacoes
12:21:43,432 DEBUG CollectionLoadContext:206 - collection fully initialized: [entidades.bdufop.Sistema.aplicacoes#ACESSO] <----
12:21:43,436 DEBUG CollectionLoadContext:206 - collection fully initialized: [entidades.bdufop.Sistema.aplicacoes#ACESSO ] <----
12:21:43,441 DEBUG CollectionLoadContext:272 - 2 collections initialized for role: entidades.bdufop.Sistema.aplicacoes
So, I think that java.lang.String and java.lang.Character are differents, but not to character and to character varying...space placed for the size of character is that it varies or not, so....hibernate would have or not to work with the type (SGDB) to character as it works with character varying?!
I think too....this is not a hibernate user forum topic!
Fred
--
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
17 years
[Hibernate-JIRA] Created: (HHH-2731) wrong delete statement for elements in collections with formula properties
by Giorgio Massussi (JIRA)
wrong delete statement for elements in collections with formula properties
--------------------------------------------------------------------------
Key: HHH-2731
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2731
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Environment: Hibernate 3.2.4 sp1 with oracle 10
Reporter: Giorgio Massussi
I have mapped a collection of components in a class; the component declares a formula property:
<class name="Master" table="MASTERS">
...
<set name="details" table="DETAILS" cascade="persist,merge,save-update" >
<key>
...
</key>
<composite-element class="Detail">
....
<property name="formula" type="int" >
<formula>1</formula>
</property>
</composite-element>
</set>
</class>
Hibernate generates a delete statement with a wrong where clause on the formula column:
delete from DETAILS where [ .... ] and null = 1
I suspect that the problem is in the constructor of org.hibernate.persister.collection.AbstractCollectionPersister: it calculates correctly the set of columns to use in where clauses, excluding formula and nullable columns, but then this fragment of code forces to keep all columns, including formulas
//workaround, for backward compatibility of sets with no
//not-null columns, assume all columns are used in the
//row locator SQL
if ( !hasNotNullableColumns ) {
Arrays.fill( elementColumnIsInPrimaryKey, true );
}
I suspect that there is the same error is in update statement.
--
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
17 years
[Hibernate-JIRA] Commented: (HHH-1364) Defensive check of isClosed when obtaining a connection from ConnectionManager
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1364?page=c... ]
Gail Badner commented on HHH-1364:
----------------------------------
Please use the user forum (http://forum.hibernate.org/) to ask for help.
> Defensive check of isClosed when obtaining a connection from ConnectionManager
> ------------------------------------------------------------------------------
>
> Key: HHH-1364
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1364
> Project: Hibernate3
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.1
> Environment: Particularly bad in J2EE environments, where thread stale thread-local connections show up in an unpredictable manner as threads are re-used.
> Reporter: Damon Feldman
> Assignee: Steve Ebersole
> Priority: Minor
> Fix For: 3.1.2
>
> Original Estimate: 20 minutes
> Remaining Estimate: 20 minutes
>
> A null connection is returned to the caller, causing a NPE in another part of the system if a connection is set to null AND the ConnectionManager is closed.
> ---- EXISTING CODE from ConnectionManager ----
> /**
> * Retrieves the connection currently managed by this ConnectionManager.
> * <p/>
> * Note, that we may need to obtain a connection to return here if a
> * connection has either not yet been obtained (non-UserSuppliedConnectionProvider)
> * or has previously been aggressively released (if supported in this environment).
> *
> * @return The current Connection.
> *
> * @throws HibernateException Indicates a connection is currently not
> * available (we are currently manually disconnected).
> */
> public Connection getConnection() throws HibernateException {
> if ( connection == null && !isClosed ) {
> openConnection();
> }
> return connection;
> }
> --------------------- RECOMMENDATION -----------
> public Connection getConnection() throws HibernateException {
> if ( connection == null) {
> if(isClosed )
> throw new HibernateException("A Connection Manager that has been closed cannot supply a Connection.");
> openConnection();
> }
> return connection;
> }
--
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
17 years
[Hibernate-JIRA] Commented: (HBX-716) Trick to help maintenance of HQL query.
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-716?page=co... ]
Max Rydahl Andersen commented on HBX-716:
-----------------------------------------
sorry for the late answer; but yes this needs to be a seperate exporter/set of templates that generates a interface that you can use in your code to get better HQL typesafety.
If your classes needs to implement this interface they can do so by adding <meta attribute="interface">IApplicationProperties</meta> assuming you configured the template to generate via the pattern "I${class-name}Properties"
> Trick to help maintenance of HQL query.
> ---------------------------------------
>
> Key: HBX-716
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-716
> Project: Hibernate Tools
> Issue Type: Patch
> Components: hbm2java
> Affects Versions: 3.2beta6
> Reporter: Francois Jean
> Priority: Minor
> Attachments: patch.txt
>
>
> I'm just sending a modification I made to a FreeMarket template in Hibernate Tools (hbm2java) to help us maintaining our HQL.
> We are using a large database with more the 300 tables and we often do a reverse-engineering of the database to keep our Java entities in synch and sometimes we have to deal with column names change. After the reverse-engineering process, the compiler will show errors for all the getter/setter that have change name. But it will not show any errors in HQL using "old" attribute names.
> For example if we have a table "Application" with a column "Version_num", we would get a Class "Application" with an attribute "versionNum" and its own getter and setter. If the column "Version_num" change its name for "App_version_num", the new attribute name will be "appVersionNum" with its new getter/setter. And the compiler will show errors for old code using the getter "getVersionNum". But will not show any errors for HQL like: "from " +Application.class.getName() + " where versionNum = 3"
> Solution:
> We modify the generation of the entity to include a constant string for each attribute name, by using these constants the compiler can flag error in HQL. The new HQL would be:
> "from " +Application.class.getName() + " where "+ Application.VERSIONNUM + " = 3"
> For now, we always generate these constants but it could be possible to trigger the constants generation by using a parameter in the ant task when asking Hibernate Tools to generate Java entities.
> Template that was modified: PojoFields.ftl
> // Fields name constant
>
> <#foreach field in pojo.getAllPropertiesIterator()><#if pojo.getMetaAttribAsBool(field, "gen-property", true)>
> public static final String ${field.name?upper_case} = "${field.name}";
> </#if>
> </#foreach>
>
> // Fields
> <#foreach field in pojo.getAllPropertiesIterator()><#if pojo.getMetaAttribAsBool(field, "gen-property", true)> <#if pojo.hasMetaAttribute(field, "field-description")> /**
> ${pojo.getFieldJavaDoc(field, 0)}
> */
> </#if> ${pojo.getFieldModifiers(field)} ${pojo.getJavaTypeName(field, jdk5)} ${field.name}<#if pojo.hasFieldInitializor(field, jdk5)> = ${pojo.getFieldInitialization(field, jdk5)}</#if>;
> </#if>
> </#foreach>
> PS: This solution is not perfect, a better approach would be something that would also validate at compilation time the type of association. For example, the association "person.address.city" present in a HQL statement will only be validated when this HQL will be executed.
> François J.
--
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
17 years
[Hibernate-JIRA] Commented: (HHH-1699) "where" attribute not include to join condition
by Julien HENRY (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1699?page=c... ]
Julien HENRY commented on HHH-1699:
-----------------------------------
Same problem for me (but with only one entity) :
<class name="Employee" table="employee" where="system='f'">
...
<many-to-one name="inlineSuperior" class="Employee" lazy="true"...
I get :
select * from employee e1, employee e2
where e1.inlineSuperior=e2.id(+)
and (
e1.system='f'
)
Should be:
select * from employee e1, employee e2
where e1.inlineSuperior=e2.id(+)
and (
e1.system='f'
)
and (
e2.system='f'
)
> "where" attribute not include to join condition
> -----------------------------------------------
>
> Key: HHH-1699
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1699
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Reporter: Renat Yusupov
> Priority: Critical
>
> So,
> <class name="SomeObject1" table="table1" where="system='f'">
> ...
> and
> <class name="SomeObject2" table="table2">
> ...
> <many-to-one name="someobject1" class="SomeObject1" lazy="true" ...
> In HQL query:
> "from SomeObject2 a join fetch a.someobject1"
> generated folowing SQL:
> select * from table2 inner join table1 on (table2.someobject1_id=table1.id)
> In this query where attribute is absent.
> Right folowing SQL:
> select * from table2 inner join table1 on (table2.someobject1_id=table1.id and table1.system='f' )
> I pached AbstractEntityPersister.
> There is diff:
> 2514a2515
> > ,getSQLWhereString(generateTableAlias( name, j ))
--
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
17 years