[Hibernate-JIRA] Commented: (HHH-952) Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
by Jon Seymour (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-952?page=co... ]
Jon Seymour commented on HHH-952:
---------------------------------
With 3.2.4.SP1, the following lines of the patch cause a null pointer exception:
+ protected String generateRootAlias(final String description) {
+ return innerQuery.getRootSQLALias();
+ }
The apparent reason for this is that generateRootAlias gets called by the base constructor before the inner (sub-)class' initializer is complete so innerQuery is null at the time generateRootAlias() is called.
I will post an updated patch if I find one.
> 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: Hibernate3
> 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
> Priority: Critical
> Attachments: 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
17 years, 7 months
[Hibernate-JIRA] Created: (HHH-2644) hbm2ddl.auto creates nullable column for primitive boolean on Derby database
by Noel Grandin (JIRA)
hbm2ddl.auto creates nullable column for primitive boolean on Derby database
----------------------------------------------------------------------------
Key: HHH-2644
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2644
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.0.ga
Environment: Hibernate 3.2,
Derby 10.2.20
Reporter: Noel Grandin
Priority: Minor
I have
hibernate.hbm2ddl.auto=update
and I have an existing database with existing tables.
I updated one of the domain objects to have a new boolean field.
When I started my app, it failed when it tried to load the domain object, with the following stacktrace:
[0@15:39:41.551] !SE>: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of peralex.grj8000.datastore.SweepJamBand.selected
at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:82)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3514)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
at peralex.client.control.Control.loadSelectedLibrary(Control.java:334)
Caused by: java.lang.IllegalArgumentException
at sun.reflect.UnsafeBooleanFieldAccessorImpl.set(UnsafeBooleanFieldAccessorImpl.java:62)
at java.lang.reflect.Field.set(Field.java:656)
at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:79)
... 36 more
When I looked in the database, I noted that the table had been incorrectly updated with a nullable column for the new field.
Using my debugger I confirmed that Hibernate was attempting to load a "null" value into a primitive boolean field.
I worked around this by specifying
@Column(columnDefinition="smallint not null default 0" )
private boolean selected;
on my new field.
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-2643) Improve Session.refresh() Javdoc to clarify contract
by Chris Bredesen (JIRA)
Improve Session.refresh() Javdoc to clarify contract
----------------------------------------------------
Key: HHH-2643
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2643
Project: Hibernate3
Issue Type: Improvement
Components: documentation
Reporter: Chris Bredesen
Assignee: Chris Bredesen
Priority: Minor
It is tempting to use refresh() as an "undo" method when it was not designed as such. The manual is clear about how refresh() should be used, but doesn't mention how it should NOT be used. Refresh will not work on the following case:
Cat cat = s.get(Cat.class, new Long(1l));
cat.getKittens.add(new Cat());
s.refresh(cat);
It results in this:
2012 ERROR org.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null identifier
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:39)
at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:74)
The presence of cascade type REFRESH makes it sound like this should work. The documentation needs to be more specific about not using refresh() as an undo facility. Hibernate itself is not a transaction handler.
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-2642) InformixDialect generates invalid Aliases for Informix 7
by Thom Hehl (JIRA)
InformixDialect generates invalid Aliases for Informix 7
--------------------------------------------------------
Key: HHH-2642
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2642
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.0 final
Environment: Informix 7.31
Reporter: Thom Hehl
With Informix JDBC drivers and InformixDialect, Hibernate 3 builds the following query:
select participan0_.PART_NO as PART1_12_0_, participan0_.FNAME as FNAME12_0_,
participan0_.LNAME as LNAME12_0_,
participan0_.ADDRESS as ADDRESS12_0_,
participan0_.city as city12_0_, participan0_.state as state12_0_,
participan0_.zip as zip12_0_, participan0_.DOB as DOB12_0_,
participan0_.DATE_SELECTED1 as DATE9_12_0_,
participan0_.h_phone as h10_12_0_,
participan0_.SIN as SIN12_0_, participan0_.SEX as SEX12_0_,
participan0_.citizen as citizen12_0_, participan0_.race as race12_0_,
participan0_.hispanic as hispanic12_0_,
participan0_.NOTES as NOTES12_0_,
participan0_.STATUS as STATUS12_0_
from INFORMIX.VOTERS participan0_
where participan0_.PART_NO='100025595'
and ADDRESS12_0_ = 'PO BOX 20 '
The problem is that Informix 7.3.1 doesn't see the ADDRESS12_0_ as a valid alias and throws a SQL exception. This works under Informix 9.
We need an Informix 7 dialect that will support this query without throwing an exception.
Thanks.
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-2639) HQL parser treats closing (right) parenthesis wrong
by Barak Ori (JIRA)
HQL parser treats closing (right) parenthesis wrong
---------------------------------------------------
Key: HHH-2639
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2639
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Environment: Hibernate 3.2.1 against Oracle 10g.
Reporter: Barak Ori
The following HQL query "from Employee e where e.id > 100)" (notice the extra right parenthesis) works fine, although the parentheses are not balanced. It works as if the last parenthesis doesn't exist.
The following HQL query also works: "from Employee e where e.id > 100)) and e.id < 1000", and returns results like the previous query.
It looks like the first time an extra right parenthesis is found, it marks the end of the HQL query, and everything else is ignored.
I've encountered this since I have a large piece of code that generates HQL queries dynamically. One component failed to balance parentheses properly, and the query didn't fail - instead it returned wrong results (imagine a this problematic HQL fragment as in inner query...) I think a parsing error on such queries is much nicer than accepting them and returning wrong 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
17 years, 7 months