[Hibernate-JIRA] Created: (HHH-6661) Parent-child self-referencing relationship via link table causes QuerySyntaxException:(table) is not mapped when retrieving previous revisions
by Gerard Krupa (JIRA)
Parent-child self-referencing relationship via link table causes QuerySyntaxException:(table) is not mapped when retrieving previous revisions
----------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-6661
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6661
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.7
Environment: Hibernate 3.6.7.Final, Oracle 11g DB (also reproduced with Derby 10.8.1.2), Spring 3.0.3
Reporter: Gerard Krupa
Attachments: gjkrupa_envers_problem.zip
We have a parent-child relationship set up for an entity using a plain link table. This is annotated with @JoinTable and @AuditJoinTable so there is no entity for the link table itself. The definition looks something like this...
@Entity
@Table(name = "BKG_BKCM_BKG_CMPT")
@Audited
public class BookingComponent implements Serializable {
@ManyToOne(fetch = FetchType.LAZY, optional = true)
@AuditJoinTable(name = "BKG_BKCMR_REL_AUD", inverseJoinColumns = { @JoinColumn(name = "BKCM_ID_PARENT", nullable = true, updatable = false) })
@JoinTable(name = "BKG_BKCMR_REL", joinColumns = { @JoinColumn(name = "BKCM_ID_CHILD", nullable = true, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "BKCM_ID_PARENT", nullable = true, updatable = false) })
private BookingComponent parent;
@OneToMany(mappedBy = "parent")
private List<BookingComponent> children;
}
We've found two issues. Firstly, when we try to retrieve a previous revision of these entities (they in turn are held in a collection in a container entity) using List<>.size() Envers seems to be constructing a JPQL query using the link table's table name which isn't valid JPQL resulting in the following exception:
org.hibernate.hql.ast.QuerySyntaxException: BKG_BKCMR_REL_AUD is not mapped [select new list(ee, e) from BKG_BKCMR_REL_AUD ee, *package-name-omitted*.BookingComponent_AUD e where ee.originalId.BookingComponent_id = e.originalId.id and ee.originalId.children_id = :children_id and e.originalId.rev_id.id <= :revision and ee.originalId.rev_id.id <= :revision and ee.rev_type != :delrevisiontype and e.rev_type != :delrevisiontype and (e.REV_ID_END.id > :revision or e.REV_ID_END is null) and (ee.REV_ID_END.id > :revision or ee.REV_ID_END is null)]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:111)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:327)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3441)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3325)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:733)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:584)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
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:124)
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:1770)
at org.hibernate.envers.entities.mapper.relation.query.TwoEntityQueryGenerator.getQuery(TwoEntityQueryGenerator.java:128)
at org.hibernate.envers.entities.mapper.relation.lazy.initializor.AbstractCollectionInitializor.initialize(AbstractCollectionInitializor.java:62)
at org.hibernate.envers.entities.mapper.relation.lazy.proxy.CollectionProxy.checkInit(CollectionProxy.java:50)
at org.hibernate.envers.entities.mapper.relation.lazy.proxy.CollectionProxy.size(CollectionProxy.java:55)
We've also noticed that the audit entries for the link table have a null REV_ID_END despite there being multiple revisions.
See attached gjkrupa_envers_problem.zip for a test case that demonstrates this issue.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 8 months
[Hibernate-JIRA] Created: (HHH-4959) Concurrent HQL parsing blocks on ReflectHelper.classForName()
by Jarl Totland (JIRA)
Concurrent HQL parsing blocks on ReflectHelper.classForName()
-------------------------------------------------------------
Key: HHH-4959
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4959
Project: Hibernate Core
Issue Type: Improvement
Components: query-hql
Affects Versions: 3.3.2
Environment: DB2
Reporter: Jarl Totland
Priority: Minor
Attachments: ReflectHelper.java
For particularly HQL-heavy applications, concurrency is lost as ReflectHelper.classForName() blithely runs loadClass() for tokens again and again, many of which are not even classes. As loadClass() is synchronized it end up blocking while it generates stacktraces for its exceptions. This goes for both classic and AST parsers.
Because of this blocking our regression tests took over 20 minutes, regardless of number of threads.
Implementing a simple cache from String to Class in ReflectHelper.classForName() reduced this to 3 minutes for eight threads on a dual-core cpu; the bottleneck is now the database as it should be, not lock contention.
The issue was reported earlier in HHH-1810, but dismissed as related to the classic parser only.
We might use HQL in inappropriate ways, but still wouldn't hurt for Hibernate to support this.
Attached is our modified ReflectHelper; modified code is in the classForName()-methods, classForNameInternal(), and the static HashMap<String, Object> classes.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-5274) HQL-Insert with Select and Sub-Select fails
by Björn Moritz (JIRA)
HQL-Insert with Select and Sub-Select fails
-------------------------------------------
Key: HHH-5274
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5274
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2, Oracle 10 (using org.hibernate.dialect.Oracle10gDialect)
Reporter: Björn Moritz
Attachments: Testcase.zip
In Hibernate 3.5.2 a HQL-Insert statement doing a select using a subselect is failing. This is due to a wrong replacement of the table name in the generated SQL-Statement.
The following statement will work:
{code:sql}select a.id from A a where exists (select 1 from B b where b.id = a.id){code}
but an insert statement embedding the same statement does not work:
{code:sql}insert into C (id) select a.id from A a where exists (select 1 from B b where b.id = a.id){code}
The latter statement will thrown an SqlSyntaxErrorException as the second 'a.id' will get replaced with 'AAA.id' (which is the real table name and not the alias used in the generated sql statement).
In Hibernate 3.1.3 both statements worked fine.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-6891) Hibernate is not reusing connections from the pool
by Mat Banik (JIRA)
Hibernate is not reusing connections from the pool
--------------------------------------------------
Key: HHH-6891
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6891
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.CR7
Environment: Hibernate 4, MySQL 5.6
Reporter: Mat Banik
I have tried two connection pool providers C3P0 and Commons DBCP. Both are the most current versions.
Everything starts fine. And data is loading from database as expected.
But with C3P0 when left to defaults everything stops when maximum of 15 connections are reached. Nothing is freed up and the application behaves like it has memory leak.
Here is bottom of log output
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG begin
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG Obtaining JDBC connection
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG acquire test -- pool is already maxed out. [managed: 15; max: 15]
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG awaitAvailable(): com.mchange.v2.c3p0.impl.NewPooledConnection@46f0decc
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG trace com.mchange.v2.resourcepool.BasicResourcePool@9671641 [managed: 15, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@46f0decc)
With Commons DBCP everything work as well until when maximum connections are reached and than it throws exception:
org.springframework.orm.hibernate4.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [null]; error code [0]; Could not open connection; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:165) org.springframework.orm.hibernate4.HibernateExceptionTranslator.convertHibernateAccessException(HibernateExceptionTranslator.java:50) org.springframework.orm.hibernate4.HibernateExceptionTranslator.translateExceptionIfPossible(HibernateExceptionTranslator.java:37) org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58) org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 8 months
[Hibernate-JIRA] Created: (HV-560) Investigate how reference from API packages to Log class could be avoided
by Gunnar Morling (JIRA)
Investigate how reference from API packages to Log class could be avoided
-------------------------------------------------------------------------
Key: HV-560
URL: https://hibernate.onjira.com/browse/HV-560
Project: Hibernate Validator
Issue Type: Task
Components: engine
Affects Versions: 4.3.0.Alpha1
Reporter: Gunnar Morling
With HV-481 some references from API packages to the new {{Log}} class (which lives in the {{internal}} package) were introduced. Due to some limitations of the JBoss logging annotation processor there seems currently no way around this. Ideally the following would be possible:
* The API classes can have private inner Log interfaces with their log messages
* The package for the generated classes can be specified so that they can be generated into an internal package
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 8 months
[Hibernate-JIRA] Created: (HHH-6662) @AssociationOverride with @JoinTable does not work
by Richard Kohl (JIRA)
@AssociationOverride with @JoinTable does not work
--------------------------------------------------
Key: HHH-6662
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6662
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.7
Environment: Hibernate 3.6.7.Final
Reporter: Richard Kohl
Priority: Critical
Attachments: test-case.zip
@AssociationOverride is completely ignored when used with @JoinTable (test case encloded, but it will probably happen always).
I looked through the Hibernate code and that reason for that is probably the typo in org.hibernate.cfg.AbstractPropertyHolder.buildHierarchyColumnOverride(XClass), particulary lines:
currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
Instead, the should be:
currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
currentJoinTableOverride.putAll( joinTableOverride); //subclasses have precedence over superclasses
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 8 months