[Hibernate-JIRA] Created: (HHH-5456) Query plan for query using filter with variable number of parameters is incorrectly re-used
by Mike Q (JIRA)
Query plan for query using filter with variable number of parameters is incorrectly re-used
-------------------------------------------------------------------------------------------
Key: HHH-5456
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5456
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Reporter: Mike Q
It looks like the QueryPlanCache is incorrectly reusing an existing query plan when it shouldn't. This happens in the following situation
- A filter is used by the query
- The filter has one parameter where the values are a Collection/Array
- The number of parameter values changes from query to query
Debugging the hibernate code it looks like HQLQueryPlanKey is not correctly considering the NUMBER of parameter values for enabled filters.
To reproduce do the following.
- Define an entity with a single filter def and filter with one parameter
e.g.
@FilterDef( name="partitions", parameters = @ParamDef( name="partitionIds", type="integer" ) )
@Filters( {
@Filter( name="partitions", condition="partitionId in ( :partitionIds )" )
} )
public class Account
- Create a new session
- Enable the "partitions" filter
- Define a list of length 2 and set the "partitionIds" parameter on the filter
- Execute the query
- Works fine
- Close session
- Create a new session
- Enable the "partitions" filter
- Define a list of length 1 and set the "partitionIds" parameter on the filter
- Execute the query
- Exception executing query because the plan generated from the first query is being used again which expects two parameters (?, ?) in the list when only one is being supplied in this instance.
Suggested fix.
Modify QueryPlanCache.HQLQueryPlanKey to account for the number of parameters in the enabled filters in addition to the filter names. The information is passed in to the constructor of HQLQueryPlanKey should this shouldn't be difficult to fix.
Also noticed that FilterQueryPlanKey may suffer from the same issue.
In the meantime is there any workaround for this issue?
--
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, 4 months
[Hibernate-JIRA] Commented: (HHH-4407) Add support for custom code-based enums in EnumType - such as mapping ISO codes to gender Enums
by Sachinkumar Kantilal Tailor (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4407?page=c... ]
Sachinkumar Kantilal Tailor commented on HHH-4407:
--------------------------------------------------
import org.hibernate.type.MappedEnum;
This is very useful code for us. Hope to see in future release. I stuck to create my own custom enum type which store value instead of ordinal in db. Example show us is very easy. Will it store value directly ?
Thanks
Sachin
> Add support for custom code-based enums in EnumType - such as mapping ISO codes to gender Enums
> -----------------------------------------------------------------------------------------------
>
> Key: HHH-4407
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4407
> Project: Hibernate Core
> Issue Type: Improvement
> Components: annotations
> Reporter: Steve Ebersole
> Priority: Minor
> Attachments: MappedEnum.java.patch
>
>
> Now, this could be seen as an improvement to EnumType that's specific to a business domain, but I'm thinking it could help in the general case. Right now we can map JDK enums to several database types, such as INT, VARCHAR, etc. Each of these approaches have some drawbacks, depending on the domain:
> 1) The int mapping is not very reliable through refactorings. An enum that's mapped to a "0" or "2" integer value in the database could end up mapped as a different value if a future refactoring adds an additional enum with an ordinal of 0.
> 2) The varchar mapping could use the enum name instead of its ordinal. But again, if the enum changes, the mapping gets lost and it needs manual changes. It's also heavier on the performance side.
> A useful approach for enum mappings is to use common codes to represent them in the database. That depends of course of the domain logic that's being used. A useful example is the Human sex mapping, defined in ISO code 5218:
> http://en.wikipedia.org/wiki/ISO_5218
> * 0 = not known,
> * 1 = male,
> * 2 = female,
> * 9 = not specified.
> For this to work, the Sex enum could have a property "isoCode" that specifies the mapping between the database integer code and the Java enum.
> For other domain examples additional examples could be specified.
> The EnumType could include a parameter that indicates the property to be evaluated for code-mapping, performing the translation in this way. Of course, reflection cache / byte-code generation / whatever could be specified to speed up the process.
> As always, patches are offered if you think this improvement is viable.
--
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, 4 months
[Hibernate-JIRA] Commented: (HHH-1909) Incomplete insert and update using <<insert="false" update="false">>
by Mario Balaban (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909?page=c... ]
Mario Balaban commented on HHH-1909:
------------------------------------
Have similar problem. I used hibernate tools to generate the entities, dao, and hbm files. Now when I'm trying to save the entity Iscritti that have this part as the Iscritti.hbm.xml : ...
<class name="com.model.Iscritti" table="ISCRITTI">
<many-to-one name="agenzie" class="com.model.Agenzie" update="false" insert="false" fetch="select">
<column name="ABI" length="5" not-null="true" />
<column name="CAB" length="5" not-null="true" />
</many-to-one>
.... and this is Agenzie.hbm.xml ...
<class name="com.model.Agenzie" table="AGENZIE">
<composite-id name="id" class="com.model.AgenzieId">
<key-property name="abi" type="string">
<column name="ABI" length="5" />
</key-property>
<key-property name="cab" type="string">
<column name="CAB" length="5" />
</key-property>
</composite-id>
....
I get an Exception saying that the column CAB cannot be null, even if the property "agenzie" of Iscritti have been set with an entity retrieved from the DB. An indeed in the sql produced by Hibernate does not set this column when persisting the entity Iscritti.
> Incomplete insert and update using <<insert="false" update="false">>
> --------------------------------------------------------------------
>
> Key: HHH-1909
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0 final
> Reporter: Peppe
> Priority: Critical
>
> Hi, I've seen lots of people have problems using complex mappings.
> This is my situation, I've three mappings:
> <hibernate-mapping>
> <class name="unibiblio.dati.anagrafica.DAO.Persone" table="persone">
> <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.PersoneId">
> <key-property name="idUtente" type="java.lang.Integer">
> <column name="id_utente" />
> </key-property>
> <key-property name="codbib" type="java.lang.Integer">
> <column name="codbib" />
> </key-property>
> </composite-id>
> <many-to-one name="dizTitolidistudio" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" />
> <column name="codice_titolostudio" length="1" />
> </many-to-one>
> <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" fetch="select">
> <column name="lingua" length="2" />
> </many-to-one>
> <many-to-one name="dizProfessioni" class="unibiblio.dati.anagrafica.DAO.DizProfessioni" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" />
> <column name="codprofessione" length="2" not-null="true" />
> </many-to-one>
> <property name="userName" type="string">
> <column name="user_name" length="30" />
> </property>
> <property name="password" type="string">
> <column name="password" length="30" />
> </property>
> .
> .
> .
> .
> .
> .
> </class>
> </hibernate-mapping>
> <hibernate-mapping>
> <class name="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" table="diz_titolidistudio">
> <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudioId">
> <key-property name="lingua" type="string">
> <column name="lingua" length="2" />
> </key-property>
> <key-property name="codiceTitolostudio" type="string">
> <column name="codice_titolostudio" length="1" />
> </key-property>
> </composite-id>
> <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" not-null="true" />
> </many-to-one>
> <property name="titolo" type="string">
> <column name="titolo" length="50" not-null="true" />
> </property>
> <set name="persones" inverse="true">
> <key>
> <column name="lingua" length="2" />
> <column name="codice_titolostudio" length="1" />
> </key>
> <one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
> </set>
> </class>
> </hibernate-mapping>
> <hibernate-mapping>
> <class name="unibiblio.dati.anagrafica.DAO.DizProfessioni" table="diz_professioni">
> <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizProfessioniId">
> <key-property name="lingua" type="string">
> <column name="lingua" length="2" />
> </key-property>
> <key-property name="codprofessione" type="string">
> <column name="codprofessione" length="2" />
> </key-property>
> </composite-id>
> <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
> <column name="lingua" length="2" not-null="true" />
> </many-to-one>
> <property name="professione" type="string">
> <column name="professione" length="50" />
> </property>
> <set name="persones" inverse="true">
> <key>
> <column name="lingua" length="2" />
> <column name="codprofessione" length="2" not-null="true" />
> </key>
> <one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
> </set>
> </class>
> </hibernate-mapping>
> The problem is when I try to insert a new persone it make an incomplete SQL statement because
> <<update="false" insert="false">> in <many-to-one name="dizTitolidistudio"> and <many-to-one name="dizProfessioni">
> causes hiding setting of columns "codice_titolostudio" and "codprofessione" in the generated SQL
> Deleting that tag, of course, give me the exception
> ERROR [STDERR] org.hibernate.MappingException: Repeated column in mapping for entity: unibiblio.dati.anagrafica.DAO.Persone column: lingua (should be mapped with insert="false" update="false")
>
> I workarounded this extracting "codice_titolostudio" and "codprofessione" as properties in Persone and setting them with
> classes but I don't like this. Am I wrong or is it a bug?
--
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, 4 months
[Hibernate-JIRA] Assigned: (HHH-1570) criteria-api: filtering by key-many-to-one causes invalid sql
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1570?page=c... ]
Steve Ebersole reassigned HHH-1570:
-----------------------------------
Assignee: Steve Ebersole
> criteria-api: filtering by key-many-to-one causes invalid sql
> -------------------------------------------------------------
>
> Key: HHH-1570
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1570
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.5.3, 3.6.0.Beta1
> Reporter: Joris Verschoor
> Assignee: Steve Ebersole
> Attachments: HHH-1570-fix.patch, HHH-1570-it.patch, hibernate.patch
>
>
> We have a class Price that has a composite-id using a couple of key-properties and some key-many-to-ones)
> One of those is "transportation", which has a many-to-one to transportationType
> When we query using: criteria.add(Expression.eq("price.transportation.transportationType.id", transId);, we get an invalid SQL statement: The table of transportation was not selected.
> I will try to make a testcase today or tomorrow, depending on my schedule.. Things will be more clear by then...
> We have created a work-around, by mapping the transportationID twice: once in key-property, and once as a many-to-one. (instead of one key-many-to-one)
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-4904) result of 'join fetch' query is incorrectly cached
by Geoff Crain (JIRA)
result of 'join fetch' query is incorrectly cached
--------------------------------------------------
Key: HHH-4904
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4904
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.3.2
Environment: hibernate 3.3.2, EhCache 1.2.3, postgresql, mysql and hsql
Reporter: Geoff Crain
Im not sure if this is either a bug, a missing option, or just an option that i can't find.
Im using hibernate 3.3.2, and EhCache 1.2.3.
I recently had an issue where objects in collections were getting dropped from the cache. After a long investigation, I found that it was because a "join fetch" query was being made on the parent object. http://docs.jboss.org/hibernate/core/3. ... ryhql.html
This meant that only a subset of the child elements were selected. If the collection was not already in the cache, the "incomplete" result of this query is put into it. Every subsequent call to the parent element (wanting the "full" set of children) would only get this incomplete version. When the incomplete version drops out of the cache (after 24 hours) everything goes back to normal.
So, is it a bug? Should hibernate (or ehcache) not be caching this "incomplete" collection? Or is there some way to tell hibernate that it is an incomplete collection _so_ that it doesnt get cached?
* If you believe this to be a bug, I will provide a working example.
* If you think this is actually an EhCache bug, tell me and Ill raise it there
--
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, 4 months