[Hibernate-JIRA] Created: (HHH-5752) revisionFieldName overide causes invalid column aliases on many-to-many relationships
by Adam Evans (JIRA)
revisionFieldName overide causes invalid column aliases on many-to-many relationships
-------------------------------------------------------------------------------------
Key: HHH-5752
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5752
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.6
Environment: MySql5
Reporter: Adam Evans
Had a issue which took a good while to track down.
When using AuditReader.find(Entity.clas, id, revision) to pull back a revision of a entity a SQL exception was given with a non unique column alias on entities with a many-to-many field, other entites without manytomany worked.
It looks like the query was generating a duplicate '_revision' field without using an column alias. '_revision' was set using the property overide 'org.hibernate.envers.revisionFieldName=_revision' .
Below is a copy of the failing query:
{code:sql}
SELECT _revision AS col_0_0_,
assoc_acti0_.activity_id AS col_0_1_,
assoc_acti0_.facility_id AS col_0_2_,
facility_v1_.id AS col_1_0_,
_revision AS col_1_1_
FROM assoc_activity_facility_versions assoc_acti0_
CROSS JOIN facility_versions facility_v1_
WHERE assoc_acti0_.facility_id = facility_v1_.id
AND assoc_acti0_.activity_id = 1
AND _revision = (SELECT MAX(_revision)
FROM facility_versions facility_v2_
WHERE _revision <= 1
AND facility_v1_.id = facility_v2_.id)
AND _revision = (SELECT MAX(_revision)
FROM assoc_activity_facility_versions assoc_acti3_
WHERE _revision <= 1
AND assoc_acti0_.activity_id =
assoc_acti3_.activity_id
AND assoc_acti0_.facility_id =
assoc_acti3_.facility_id)
AND _rev_type <> 2
AND _rev_type <> 2
{code}
After lots of debugging trying to create test cases based on my entity relationships which where passing without problem it occurred on the test project i'd not overiden 'org.hibernate.envers.revisionFieldName' . As soon as I set this property the test cases started failing. Removing this property from the original project, aliases are generated correctly and audited entities with many to many relatioships can now be retreivied. Below is the working sql generated with 'org.hibernate.envers.revisionFieldName' not set.
{code:sql}
SELECT assoc_acti0_.rev AS col_0_0_,
assoc_acti0_.activity_id AS col_0_1_,
assoc_acti0_.category_id AS col_0_2_,
category_a1_.id AS col_1_0_,
category_a1_.rev AS col_1_1_
FROM assoc_activity_category_aud assoc_acti0_
CROSS JOIN category_aud category_a1_
WHERE assoc_acti0_.category_id = category_a1_.id
AND assoc_acti0_.activity_id = 1
AND category_a1_.rev = (SELECT Max(category_a2_.rev)
FROM category_aud category_a2_
WHERE category_a2_.rev<=1
AND category_a1_.id = category_a2_.id)
AND assoc_acti0_.rev = (SELECT Max(assoc_acti3_.rev)
FROM assoc_activity_category_aud assoc_acti3_
WHERE assoc_acti3_.rev<=1
AND assoc_acti0_.activity_id =
assoc_acti3_.activity_id
AND assoc_acti0_.category_id =
assoc_acti3_.category_id)
AND assoc_acti0_.revtype<>2
AND category_a1_.revtype<>2
{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
13 years, 7 months
[Hibernate-JIRA] Created: (JPA-7) JPA Support of Enum as Primary Key
by Bernard (JIRA)
JPA Support of Enum as Primary Key
----------------------------------
Key: JPA-7
URL: http://opensource.atlassian.com/projects/hibernate/browse/JPA-7
Project: Java Persistence API
Issue Type: Improvement
Affects Versions: 1.0.1
Environment: java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
Hibernate JPA as installed with latest NetBeans release 6.9.1
Reporter: Bernard
Priority: Critical
Attachments: TestCase.zip
Enums work as primary keys in TopLink and EclipseLink.
DataNucleus supports them, too:
http://www.datanucleus.org/products/accessplatform/jpa/primary_key.html
In the attached testcase, JPA, via persistence.xml, creates a database column type of
VARBINARY. The data contained in it is like:
10101100111011010000000000000101~r0000000000011000main.MyEntity$EntityType0000000000000000000000000000000000000000000000000000000000000000000100100000000000000000xr0000000000001110java.lang.Enum0000000000000000000000000000000000000000000000000000000000000000000100100000000000000000xpt0000000000000110TYPE_1 Type 1
That is not what we need.
We need an integer because in the entity class, we specify
@Enumerated(value = EnumType.ORDINAL)
While Enum as ID field is not specifically supported in the JPA specs, it is not specifically excluded, either.
It would be desirable to have the new version of the spec include this feature, too.
The attached testcase (zip file) runs with NetBeans out of the box.
--
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
13 years, 7 months
[Hibernate-JIRA] Created: (HHH-4613) HQL: QuerySyntaxException when parsing any condition containing a colum named "value"
by Guenther Demetz (JIRA)
HQL: QuerySyntaxException when parsing any condition containing a colum named "value"
-------------------------------------------------------------------------------------
Key: HHH-4613
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4613
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Beta-2
Environment: 3.5.0-Beta2, Db: HSQLDB
Reporter: Guenther Demetz
Priority: Minor
Attachments: TestCaseQueryWithCondition.jar
org.hibernate.hql.ast.QuerySyntaxException: expecting OPEN, found '=' near line 1, column 27
is thrown calling
((org.hibernate.Session) session).createQuery("from hello.A where value = ?");
Please note that until Hibernate3.3.2GA this worked fine!
Apparently 'value' unintentionally has become a reserved keyword for HQL conditions.
Here the complete stacktrace:
--> org.hibernate.hql.ast.QuerySyntaxException: expecting OPEN, found '=' near line 1, column 27 [from hello.A where value = ?]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:284)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1586)
at hello.TestQueryWithCondition.testQuery(TestQueryWithCondition.java:40)
Please consider attached junit-testcase.
best regards
Guenther Demetz
--
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
13 years, 7 months