[Hibernate-JIRA] Commented: (HHH-952) Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
by Rich Christy (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-952?page=co... ]
Rich Christy commented on HHH-952:
----------------------------------
Is there some place that shows how to apply these patches to source files? All the other delta's seem to use a different format then the top one for 3.2.4.sp1.
> Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
> --------------------------------------------------------------------------------------------
>
> Key: HHH-952
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-952
> Project: Hibernate Core
> Issue Type: Patch
> Components: core
> Affects Versions: 3.1 beta 1, 3.1 beta 2
> Environment: 3.1beta1 with MS SQL 2000 via jTDS
> Reporter: John
> Assignee: Gail Badner
> Priority: Critical
> Fix For: 3.2.6, 3.3.0.CR1
>
> Attachments: subquery-patch-3.2.4.SP1.txt, subquery-patch-311.txt, subquery-patch-313.txt, subquery-patch-31beta3.txt, subquery-patch.txt, subquery-patch.txt, SubqueryExpression.java
>
>
> The existing code in SubqueryExpression.java constructed a select statement but did not have any provisions for creating joins. Therefore, it was not possible using the criteria API to create an exists subselect that had a join, even though running the source DetachedCriteria alone works perfectly.
> For example, if this is the goal:
> select * from foo f
> where exists (select id from bar b join other o on b.o_id = o.id where o.prop = '123' and b.foo_id = f.id)
> One might try something like this:
> Criteria crit = session.createCriteria(Foo.class, fooAlias);
> DetachedCriteria barCrit = DetachedCriteria.forClass(Bar.class, barAlias);
> DetachedCriteria otherCrit = barCrit.createCriteria(Bar.OTHER_JOIN);
> otherCrit.add( Restrictions.eq(Other.PROP, "123") );
> barCrit.add( Restrictions.eqProperty( -- props to join to foo here --) );
> barCrit.setProjection( Projections.id() );
> crit.add( Subqueries.exists(barCrit) );
> However, the existing code generates something like the following, which gets an error with an unknown alias 'o':
> select * from foo f
> where exists (select id from bar b where o.prop = '123' and b.foo_id = f.id)
> This is also described here (at the end): http://forum.hibernate.org/viewtopic.php?t=942488
> The patch to SubqueryExpression.java fixes this to included the joins necessary for the filtering. This code was modeled (copied) off of code from CriteriaLoader. For me this works perfectly, but I don't understand the internals of this stuff enough to say how robust it is. Also included is a patch to the test case to enable testing of this, which was present but commented out. I did not change the contents of the test, which currently only attempts a joined subquery. This used to fail with an error, but now it works. The test does not check the results at all. (Inconsequential to the patch - Enrollment has two Ls.)
> -----side notes
> The patch file also has two other patches. The first increases the delay in BulkManipulationTest because I was getting inconsistent test results. I think that the precision on the version timestamp is not enough for 300 milliseconds delay to be enough to guarantee the test results. Also, in build.xml, there was a line that was meant to exclude the performance tests, but there was no **/*, on *, so they actually were not excluded. I changed this so the tests would complete in a reasonable amount of time. However, there is one other issue with testing that I worked around manually. After each test run, two databases (Users and Email) were left in the database. If I did not manually delete these then the number of failures on the next test run was different. This was really confusing until I figured it out because I was trying to make sure all the other testcases still passed with my patch, but even without the patch I was getting different results.
--
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
15 years, 8 months
[Hibernate-JIRA] Created: (HHH-3856) Base class alias used where joined subclass alias should have been used.
by Sagar Kar (JIRA)
Base class alias used where joined subclass alias should have been used.
------------------------------------------------------------------------
Key: HHH-3856
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3856
Project: Hibernate Core
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.2
Environment: Windows XP. Hibernate 3.2.2 ga. Database Oracle 10g
Reporter: Sagar Kar
Attachments: hibernate issue.zip
We have defined a where clause on the <class name="A" table="A" where="ind = 'A'"> tag in the parent class.
B is a joined subclass of A. B has a one to one relationship to another class X.
When we try the following statement
session.get(X.class, 1L);
It generates the following query
Hibernate:
/* load hibernate.X */ select
x0_.ID as ID3_1_,
x0_.IND as IND3_1_,
b1_.id as ID1_0_,
b1_1_.IND as IND1_0_,
b1_.X_ID as X2_2_0_
from
X x0_
left outer join
B b1_
on x0_.ID=b1_.X_ID
and (
b1_1_.ind = 'A'
)
left outer join
A b1_1_
on b1_.id=b1_1_.ID
where
x0_.ID=?
If you look at the "on " condition for B you will notice that its using b1_1_.ind='A' which is the parent's alias which hasn't been defined yet.
Hence we get a invalid identifier error.
It looks like the generated query is faulty.
Do we already have a fix for this?
I have attached the error log, hbm files, the test class and the oracle table create script.
--
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
15 years, 8 months
[Hibernate-JIRA] Commented: (EJB-199) Polymorphic association to a MappedSuperclass throws exception
by Don Tam (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-199?page=co... ]
Don Tam commented on EJB-199:
-----------------------------
I don't think TABLE_PER_CLASS is really ideal for this considering the restrictions (bi-directional associations only). What would be ideal, actually, is if AssociationOverride could also override the the targetEntity attribute of the association.
So:
@MappedSuperclass
public abstract class A {}
@Entity
public class B extends A{}
@MappedSuperclass
public abstract class C {
private A a;
@ManyToOne
public A getA() { return a; }
}
@Entity
@AssociationOverride(name="a", targetEntity=B.class)
public class D extends C {
}
> Polymorphic association to a MappedSuperclass throws exception
> --------------------------------------------------------------
>
> Key: EJB-199
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-199
> Project: Hibernate Entity Manager
> Issue Type: Bug
> Components: EntityManager
> Affects Versions: 3.2.0.cr1
> Environment: Annotations CR1, EntityManager CR1, and Hibernate 3.2 CR2
> Reporter: Markus Junginger
>
> I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception.
> The class Xyz is a super class for a couple of entity classes:
> @MappedSuperclass
> public abstract class Xyz{...}
> The following association to Xyz does not work (see exception below)
> @ManyToOne(fetch = FetchType.LAZY)
> @JoinColumns({...})
> private Xyz test;
> If it matters, each entity (the sub classes of Xyz) is annotated with
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS).
> Here's the execption:
> javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196)
> at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
> ...
> Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz
> at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40)
> at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261)
> at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
> at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868)
> at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641)
> at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188)
> ... 20 more
--
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
15 years, 8 months
[Hibernate-JIRA] Created: (HHH-3857) dyanmic update doesn't work if unsaved-value is present at ID or at version declaration
by Amardeep Singh (JIRA)
dyanmic update doesn't work if unsaved-value is present at ID or at version declaration
---------------------------------------------------------------------------------------
Key: HHH-3857
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3857
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.4
Environment: DB:Oracle 11G, WAS 6.1, Transaction suport from EJB, Spring or TransactionCallback from hibernate.
Reporter: Amardeep Singh
Priority: Minor
If unsaved-value is present at ID or version declaration the dynamic update is not working.
So the following mapping will not update the columns dynamically.
<hibernate-mapping>
<class table="LPN" name="com.xxx.LPN" dynamic-insert="true" dynamic-update="true">
<id type="java.lang.Long" column="LPN_ID" access="property" name="lpnId" unsaved-value="null">
<generator class="sequence">
<param name="sequence">LPN_ID_SEQ</param>
</generator>
</id>
<version type="java.lang.Long" column="HIBERNATE_VERSION" access="field" name="hibernateVersion"/>
but if I remove the *unsaved-value=null* from above mapping then it would start working. This is not a blocker for us but looks like we cannot have both things working at same time for us.
--
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
15 years, 8 months
[Hibernate-JIRA] Created: (HHH-3858) index attribute ignored
by Stefan Endrullis (JIRA)
index attribute ignored
-----------------------
Key: HHH-3858
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3858
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1.GA using MySQLDialect
Reporter: Stefan Endrullis
Priority: Minor
Hibernate does not care about user defined index names (at least when using MySQLDialect). I've tried to set the index name by specifying the index attribute in the column tag (I also tried it in the property tag):
<property name="venueValue" index="venue_value">
<column name="venue_value" index="venue_value" length="10" precision="0" not-null="true"/>
</property>
But hibernate seems to ignore this attribute, at least when "hbm2ddl.auto" is set to "update". Hibernate always tries (table is not writable) to create a new index, called FK31DDBD80A32043, for the venue_value column, although there exists already such an index called venue_value.
--
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
15 years, 8 months
[Hibernate-JIRA] Commented: (HHH-1643) Sub-query as function parameter - either sub-query is missed from SQL or NullPointerException raised
by Manuel Dominguez Sarmiento (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1643?page=c... ]
Manuel Dominguez Sarmiento commented on HHH-1643:
-------------------------------------------------
We built the project from source using Maven after applying this patch manually on 3.3.1 GA and it worked fine. Subqueries as function parameter now work as expected.
I can confirm that all tests pass as well. Please include this fix in the next official release.
> Sub-query as function parameter - either sub-query is missed from SQL or NullPointerException raised
> ----------------------------------------------------------------------------------------------------
>
> Key: HHH-1643
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1643
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.1.2, 3.1.3
> Environment: Hibernate 3.1.2 MS SQL Server 2K
> Reporter: Andy Shelton
> Attachments: hql-sql.patch
>
>
> The HQL grammar HQL (hql.g) allows expressions and sub-queries as parameters to functions, however the SQL Tree Transform grammar (hql-sql.g) does not, it only allows expressions. This means if you pass a sub-query as a parameter to something like "cast" for example, you will get a NullPointerException. In other cases, typically the sub-query is missed out of the resulting SQL. This is easily remedied by changing the first line of the definition of functionCall within hql-sql.g from:
> functionCall
> : #(METHOD_CALL {inFunctionCall=true;} pathAsIdent ( #(EXPR_LIST (expr)* ) )? )
> to:
> functionCall
> : #(METHOD_CALL {inFunctionCall=true;} pathAsIdent ( #(EXPR_LIST (exprOrSubquery)* ) )? )
> This modification has been tested against all the existing UnitTests in Hibernate 3.1.2 and does not cause any problems.
> I've included a patch for this.
--
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
15 years, 8 months
[Hibernate-JIRA] Commented: (HHH-912) Use of DetachedCriteria
by Sergey Pulyaev (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-912?page=co... ]
Sergey Pulyaev commented on HHH-912:
------------------------------------
There are another operations that are defined both in CriteriaImpl and DetatchedCriteria -
DetachedCriteria add(Criterion criterion)
DetachedCriteria addOrder(Order order)
DetachedCriteria createCriteria(String associationPath)
String getAlias()
DetachedCriteria setProjection(Projection projection)
I use both of these classes in my code - and i have to duplicate two methods for the same logic in case of Criteria and DetachedCriteria...
It's ugly...
The reason why i use both of the - i have to upply the same restrictions for selects and subselects - in other words - for Criteria and DetachedCriteria.
> Use of DetachedCriteria
> -----------------------
>
> Key: HHH-912
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-912
> Project: Hibernate Core
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.0.5
> Environment: All
> Reporter: Frank Verbruggen
> Priority: Minor
>
> The class org.hibernate.criterion.DetachedCriteria should represent a criteria object on which all the operations available to a Criteria object that do NOT require a Session object are available.
> Two such operations are setFirstResult() and setMaxResults().
> These are unfortunately enough not available.
> There probably are more methods missing that need to be added but these two in particular are important to me.
> See http://opensource2.atlassian.com/projects/spring/browse/SPR-1254.
> Can they be added in the next release ?
> Kind regards
> Frank Verbruggen
--
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
15 years, 8 months