[Hibernate-JIRA] Created: (HHH-4591) Criteria.createAlias not working for key-many-to-one associations of a composite-id
by Luka (JIRA)
Criteria.createAlias not working for key-many-to-one associations of a composite-id
-----------------------------------------------------------------------------------
Key: HHH-4591
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4591
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.3.2, 3.2.7, 3.2.6
Environment: Hibernate 3.2.6.ga, 3.2.7.ga, 3.3.2.ga
Database: Oragle10g
Reporter: Luka
I'm trying to create an alias to apply a filter on a composite primary-key association, but I'm getting an invalid SQL generated by the ctiteria api: in the SQL there is the filter applied in the where, but the join for the alias is missing in the from.
Here is a sample of the problem:
Mappings (I stripped non relevant info):
TableOne.hbm.xml
<hibernate-mapping default-cascade="none">
<class name="TableOne" table="TABLE_ONE" dynamic-insert="false" dynamic-update="false">
<id name="idTableOne" type="java.lang.Long" unsaved-value="null">
<column name="ID_CONTRATTO"/>
<generator class="sequence">
<param name="sequence">S_TABLE_ONE</param>
</generator>
</id>
<set name="tableOneToTableTwo" order-by="ID_TABLE_ONE" lazy="true" fetch="select" inverse="true" cascade="none">
<key>
<column name="ID_TABLE_ONE"/>
</key>
<one-to-many class="TableOneToTableTwo"/>
</set>
</class>
</hibernate-mapping>
TableOneToTableTwo.hbm.xml
<hibernate-mapping default-cascade="none">
<class name="TableOneToTableTwo" table="TABLE_ONE_TO_TABLE_TWO" dynamic-insert="false" dynamic-update="false">
<composite-id name="tableOneToTableTwoPk" class="TableOneToTableTwoPK">
<key-many-to-one name="tableOne" class="TableOne" >
<column name="ID_TABLE_ONE"/>
</key-many-to-one>
<key-many-to-one name="tabelTwo" class="TabelTwo" >
<column name="ID_TABLE_TWO"/>
</key-many-to-one>
</composite-id>
</class>
</hibernate-mapping>
TabelTwo.hbm.xml
<hibernate-mapping default-cascade="none">
<class name="TabelTwo" table="TABLE_TWO" dynamic-insert="false" dynamic-update="false">
<id name="idTableTwo" type="java.lang.Long" unsaved-value="null">
<column name="ID_TABLE_TWO"/>
<generator class="sequence">
<param name="sequence">S_TABLE_TWO</param>
</generator>
</id>
<property name="codTabelTwo" type="java.lang.String">
<column name="COD_TABLE_TWO" not-null="true" unique="false"/>
</property>
</class>
</hibernate-mapping>
Code:
Criteria hibCrit = getSession().createCriteria(TableOne.class);
hibCrit.createAlias("tableOneToTableTwo", "tableOneToTableTwo");
hibCrit.createAlias("tableOneToTableTwo.tableOneToTableTwoPk.tabelTwo", "tabelTwo");
hibCrit.add(Restrictions.eq("tabelTwo.codTabelTwo", "AAA"));
hibCrit.list();
Generated SQL using Oracle10G dialect (I stripped columns in select):
SELECT [...]
FROM TABLE_ONE this_
INNER JOIN TABLE_ONE_TO_TABLE_TWO tabelTwoco1_ ON this_.ID_TABLE_ONE = tabelTwoco1_.ID_TABLE_ONE
WHERE tabelTwo2_.COD_TABLE_TWO = ?
The "tabelTwo2_" should be the sql alias for criteria alias "tabelTwo", but the table and the join are missing in the from...
I also tried using createCriteria:
Criteria hibCrit = getSession().createCriteria(TableOne.class);
hibCrit.createAlias("tableOneToTableTwo", "tableOneToTableTwo");
Criteria tableTwoCrit = hibCrit.createCriteria("tableOneToTableTwo.tableOneToTableTwoPk.tabelTwo", "tabelTwo");
tableTwoCrit.add(Restrictions.eq("tabelTwo.codTabelTwo", "AAA"));
hibCrit.list();
But i get the same sql query.
Also upgrading Hibernate result in the same behavior.
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-7287) Problem in caching proper natural-id-values when obtaining result by naturalIdQuery
by Guenther Demetz (JIRA)
Problem in caching proper natural-id-values when obtaining result by naturalIdQuery
-----------------------------------------------------------------------------------
Key: HHH-7287
URL: https://hibernate.onjira.com/browse/HHH-7287
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.2
Environment: Database access with isolation level < SNAPSHOT
Reporter: Guenther Demetz
Problem was originally exposed by Madhumita Sadhukhan in a email to hibernate-dev(a)lists.jboss.org at Fri 4/27/2012 .
The bug (email point 6) get isolated by following matrix-test-case:
{code:title=org.hibernate.test.naturalid.mutable.MutableNaturalIdTest.java|borderStyle=solid}
@Test
public void testModificationInOtherSession() {
Session s = openSession();
Transaction t = s.beginTransaction();
User u = new User( "gavin", "hb", "secret" );
s.persist( u );
t.commit();
s.close();
s = openSession();
// Use transactionless session
assertNotNull( s.byNaturalId( User.class ).using( "name", "gavin" ).using( "org", "hb" ).load());
// CHANGE natural-id values in another session
Session other = openSession();
other.beginTransaction();
u = (User) other.byId( User.class ).getReference( u.getId() );
u.setOrg( "zz" );
other.getTransaction().commit();
other.close();
// CHANGE APPLIED
u = (User) s.byId( User.class ).getReference( u.getId() );
assertEquals(u, s.byNaturalId( User.class ).using( "name", "gavin" ).using( "org", "hb" ).load()); // found with cached old-values, OK
User u2 = (User) s.byNaturalId( User.class ).using( "name", "gavin" ).using( "org", "zz" ).load(); // the internal query will 'see' the new values, because isolation level < SERIALIZABLE
assertEquals(u, u2); // is it right here having u2 != null ? Yes, if we continue to see NaturalIdLoadAccess as a plain query. Maybe something to discuss
assertEquals("hb", u2.getOrg()); // entity itself must still contain the old value
assertNotNull( s.byNaturalId( User.class ).using( "name", "gavin" ).using( "org", "hb" ).load()); // this fails, that's the bug
s.close();
s = openSession();
s.beginTransaction();
s.delete( u );
s.getTransaction().commit();
s.close();
}
{code}
CAUSE:
The problem raises, when natural-id get resolved by query.
Here Hiberante uses the search-natural-id values for updating the cache, probably not being aware that in such situation they could differ from the natural-id-values in the current entity state. The cache-update then detects the old-values as obsolete and removes them, this explains why the second lookup with old values suddently returns null.
SOLUTION PROPOSAL:
After natural-id get resolved from query, first load the entity by identifier, and then cache the natural-id-values taking them from the entity state.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[Hibernate-JIRA] Created: (HV-456) The MethodValidator could not handle Proxied objects like in EJB environment
by Ingo Bruell (JIRA)
The MethodValidator could not handle Proxied objects like in EJB environment
----------------------------------------------------------------------------
Key: HV-456
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-456
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 4.2.0.Beta2
Environment: linux, java 1.6.0_24, hibernate-validator-4.2.0.Beta2, JBoss-5.1.0.GA
Reporter: Ingo Bruell
Using the MethodValidator with proxied objects via an interceptor in an ejb environment throws the following exception:
javax.validation.ConstraintDeclarationException: Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints. The following method itself has no parameter constraints but it is not defined on a sub-type of class de.enexoma.smartmeter.server.facade.config.ResourceBundleFacadeBean: MethodMetaData [method=public abstract java.util.Map de.enexoma.smartmeter.server.facade.ResourceBundleFacade.get(java.lang.String) throws de.enexoma.smartmeter.server.error.EnexomaException, parameterMetaData=[ParameterMetaData [type=class java.lang.String], [index=0], name=arg0], constraints=[], isCascading=false]], constraints=[], isCascading=false, hasParameterConstraints=false]
The method in the "real" class has constraints defined:
public Map<Locale,List<ResourceBundle>> get(@NotNull @Size(min=1)final String appName)
--
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, 2 months
[Hibernate-JIRA] Created: (HSEARCH-741) NPE using two fulltext filters, one of them matching nothing (some filters only)
by Sanne Grinovero (JIRA)
NPE using two fulltext filters, one of them matching nothing (some filters only)
--------------------------------------------------------------------------------
Key: HSEARCH-741
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-741
Project: Hibernate Search
Issue Type: Bug
Affects Versions: 3.4.0.Final, 3.3.0.Final, 3.2.1, 3.2.0.Final, 3.1.1.GA, 3.1.0.GA
Reporter: Sanne Grinovero
Assignee: Sanne Grinovero
Fix For: 3.5
It seems that some filter implementations are allowed to return null instead of an empty iterator if they don't match any document.
In this case if multiple filters are enabled, and they are eligible for bitset merging, and no matches where found, we get:
{code}java.lang.NullPointerException
org.hibernate.search.filter.AndDocIdSet.findFirstTargetPosition(AndDocIdSet.java:144)
org.hibernate.search.filter.AndDocIdSet.makeDocIdSetOnAgreedBits(AndDocIdSet.java:89)
org.hibernate.search.filter.AndDocIdSet.buildBitSet(AndDocIdSet.java:81)
org.hibernate.search.filter.AndDocIdSet.iterator(AndDocIdSet.java:60)
org.apache.lucene.search.IndexSearcher.searchWithFilter(IndexSearcher.java:550)
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:525)
org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:219)
org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:127)
org.hibernate.search.query.engine.impl.HSQueryImpl.getQueryHits(HSQueryImpl.java:419)
org.hibernate.search.query.engine.impl.HSQueryImpl.queryEntityInfos(HSQueryImpl.java:222)
org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.list(FullTextQueryImpl.java:206)
com.example.dao.impl.DaoImpl.search(Unknown Source)
....{code}
--
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, 2 months