[Hibernate-JIRA] Created: (HHH-5743) Criteria isMember() creates broken SQL in joined queries
by David Momper (JIRA)
Criteria isMember() creates broken SQL in joined queries
--------------------------------------------------------
Key: HHH-5743
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5743
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.0, 3.6.1
Environment: Hibernate 3.6.0,3.6.1, all databases
Reporter: David Momper
Priority: Critical
Attachments: Test.zip
This problem occurred both when using Oracle, or Derby. I assume it occurs for all databases. I also ran my test case with EclipseLink, and the test passed.
A criteria query like this:
{quote}
CriteriaQuery<Group> groupQuery = cb.createQuery(Group.class);
Root<Group> gRoot = groupQuery.from(Group.class);
//Get all groups whose leader's name is John, and has a valid visa for given country
groupQuery.where(cb.and(
cb.like(gRoot.get(Group_.groupLeader)
.get(Person_.personName), "%John%"),
cb.isMember(country,
gRoot.get(Group_.groupLeader)
.get(Person_.validVisas)
)
));
{quote}
produces the following query:
{quote}
select
group0_.GROUP_ID as GROUP1_2_,
group0_.LEADER_ID as LEADER3_2_,
group0_.GROUP_NAME as GROUP2_2_
from
GROUPS group0_,
PERSON person1_
where
group0_.LEADER_ID=person1_.PERSON_ID
and (
person1_.PERSON_NAME like ?
)
and (
? in (
select
person1_.PERSON_ID
from
PERSON person1_
)
)
{quote}
The query fails because a (character) country code is being checked for inclusion in a subquery of (int) person ids.
The subselect in the above query should be on a country, not a person. I think the whole query should look like this:
{quote}
select
group0_.GROUP_ID as GROUP1_2_,
group0_.LEADER_ID as LEADER3_2_,
group0_.GROUP_NAME as GROUP2_2_
from
GROUPS group0_,
PERSON person1_
where
group0_.LEADER_ID=person1_.PERSON_ID
and (
person1_.PERSON_NAME like ?
)
and (
? in (
select
country3_.COUNTRY_CODE
from
PERSON person1_,
PERSON_COUNTRY_VISA validvisas2_,
COUNTRY country3_
where
group0_.LEADER_ID=person1_.PERSON_ID
and person1_.PERSON_ID=validvisas2_.PERSON_ID
and validvisas2_.COUNTRY_CODE=country3_.COUNTRY_CODE
)
)
{quote}
--
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
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-6405) setFetchMode ignored in certain cases when using criteria queries
by David Mansfield (JIRA)
setFetchMode ignored in certain cases when using criteria queries
-----------------------------------------------------------------
Key: HHH-6405
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6405
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 4.0.0.Beta2, 3.6.5
Reporter: David Mansfield
Description:
Setting join type (e.g.) criteria.setJoinType("association.path", FetchType.JOIN) is ignored if the association being set is one of a few types. I believe many-to-many, and any association off of a collection-of-component. For these types of associations, the specified fetch type is ignored.
This worked in prior versions.
This has nothing to do with having additional restrictions on the same association, which is a different issue altogether.
Technical analysis:
This regression was introduced in git commit fbae6db0abaeb6f050ee97ce53d09d74886a7e47, and the fix for a possibly related issue in git commit 1c556dc775708706b6ca84251cb170d3c46f729f was not a complete fix, or rather did not fix this case scenario.
The first referenced commit split the JoinWalker.getJoinType(...) api into two methods, one with more parameters. In the base class implementation, one method or the other is called based on the type of association (see above). However, in the CriteriaJoinWalker (a subclass), the existing implementation only overrode one of these two methods, (the one with more arguments) causing calls into the other method to be handled by the base class, which did not function appropriately.
The second referenced commit introduced an override for the second method, however the implementation was incomplete, and was missing the crucial piece, specifically:
FetchMode fetchMode = translator.getRootCriteria().getFetchMode( path.getFullPath() );
which examined the explicitly set join types in the translator.
A fix will be supplied on github for 3.6.x and 4.0.
The implementation re-unifies the two methods in the CriteriaJoinWalker, using if/else to delegate to the correct super.getJoinType(...) method as appropriate.
--
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
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-6328) Hibernate's "Table" annotations does not cooperate well with custom quoting naming strategy
by Richard Eckart de Castilho (JIRA)
Hibernate's "Table" annotations does not cooperate well with custom quoting naming strategy
-------------------------------------------------------------------------------------------
Key: HHH-6328
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6328
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Affects Versions: 3.6.5
Reporter: Richard Eckart de Castilho
I have implemented a custom QuotingNamingStrategy that quotes table names, so that they are properly treated as case sensitive and to avoid issues with reserved names.
I also have auxiliary "Table" annotations to have Hibernate create indexes on my behalf. Of course the table name is not quoted in these annotations:
{code}
@org.hibernate.annotations.Table(appliesTo="MyTable",indexes = { @Index(name="column1", columnNames="column2")})
{code}
Now I get the exception:
{noformat}
org.hibernate.AnnotationException: @org.hibernate.annotations.Table references an unknown table: MyTable
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:877)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
{noformat}
Debugging the issue, I find that the EntityBinder tries to match the quoted name against the "appliesTo" attribute of the Table annotation, but the value of this attribute is not processed by my custom QuotingNamingStrategy. Thus, the table cannot be found:
{code}
public void processComplementaryTableDefinitions(org.hibernate.annotations.Table table) {
//comment and index are processed here
if ( table == null ) return;
String appliedTable = table.appliesTo();
Iterator tables = persistentClass.getTableClosureIterator();
Table hibTable = null;
while ( tables.hasNext() ) {
Table pcTable = (Table) tables.next();
// -=> Here the quoted name is compared to the unquoted name from "appliedTable"
if ( pcTable.getQuotedName().equals( appliedTable ) ) {
//we are in the correct table to find columns
hibTable = pcTable;
break;
}
hibTable = null;
}
if ( hibTable == null ) {
//maybe a join/secondary table
for ( Join join : secondaryTables.values() ) {
if ( join.getTable().getQuotedName().equals( appliedTable ) ) {
hibTable = join.getTable();
break;
}
}
}
if ( hibTable == null ) {
throw new AnnotationException(
"@org.hibernate.annotations.Table references an unknown table: " + appliedTable
);
}
if ( !BinderHelper.isEmptyAnnotationValue( table.comment() ) ) hibTable.setComment( table.comment() );
TableBinder.addIndexes( hibTable, table.indexes(), mappings );
}
{code}
I do believe that the value of the "appliedTo" attribute should be passed through the naming strategy before comparing against the table name.
--
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
12 years, 8 months
[Hibernate-JIRA] Created: (HSEARCH-821) Finalize SearchFactory API decisions
by Sanne Grinovero (JIRA)
Finalize SearchFactory API decisions
------------------------------------
Key: HSEARCH-821
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-821
Project: Hibernate Search
Issue Type: Task
Reporter: Sanne Grinovero
Priority: Blocker
When introducing HSEARCH-750 we created these methods:
{code}org.hibernate.search.SearchFactory.openIndexReader(Class<?>...)
org.hibernate.search.SearchFactory.closeIndexReader(IndexReader){code}
An alternative idea would be to add a single indirection, as for example
searchFactory.getReaderProvider().open / close
This task is about taking a final decision on that matter, and review the SearchFactory API for other methods as well.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HV-495) Many locks on AnnotatedElements
by Loïc DIAS DA SILVA (JIRA)
Many locks on AnnotatedElements
-------------------------------
Key: HV-495
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-495
Project: Hibernate Validator
Issue Type: Patch
Components: validators
Affects Versions: 4.2.0.CR1
Environment: GNU/Linux, JVM 6.0, Hibernate Validator 4.2.0.CR1
Reporter: Loïc DIAS DA SILVA
Attachments: jmeter-graph.docx, patch-ldds.patch
Hi all, we use Hibernate Validator 4.2.0-CR1 (previously Apache BVAL) for one of our API projects.
All is working fine for our needs except one big issue recently discovered during JMeter tests.
Several injectors make many requests from some Amazon cloud servers to our API and starting from a number of requests the response time begins to increase eavily, making a big jump from about 100ms in average to more than 5s.
After investigating we have seen many locks in some AnnotatedElement methods (mainly getAnnotation).
I've then made a little patch on hibernate in order to cache this kind of requests as i've not found any other cleaver/yet implemented way..
Since this patch all is working very well for us..
Regards.
--
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
12 years, 8 months