[Hibernate-JIRA] Created: (HHH-6589) Support "Any" mappings when building metamodel
by Robert Brady (JIRA)
Support "Any" mappings when building metamodel
----------------------------------------------
Key: HHH-6589
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6589
Project: Hibernate Core
Issue Type: Improvement
Components: entity-manager
Affects Versions: 3.5.6
Environment: Hibernate entity manager 3.5.5, PostgreSQL 8.4
Reporter: Robert Brady
I am upgrading from Hibernate 3.2.x to 3.5.5 and getting UnsupportedOperationExceptions thrown when Hibernate is trying to create the metamodel. This is due to the dependency of my application upon jBPM 3.x, which uses "any" mappings for some of its classes.
The exception occurs in org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(...)
{noFormat}
java.lang.UnsupportedOperationException: any not supported yet
at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:452)
{noFormat}
It is due to the logic in AttributeFactory at line 451:
{noFormat}
if ( type.isAnyType() ) {
throw new UnsupportedOperationException( "any not supported yet" );
}
{noFormat}
The "Big Hammer" approach of globally disabling the creation of the metamodel with the property setting:
{noFormat}
hibernate.ejb.metamodel.generation=disabled
{noFormat}
is not feasible: other components in my application depend upon the criteria search api, which need a generated meatamodel. Splitting the single application persistence unit into two parts ( one for the jBPM persisted classes with metamodel disabled and all other classes with metamodel enabled) is not feasible either. The split persistence unit approach would also split transaction boundaries of operations that are desired to be in a single transaction.
Hibernate should support "any" mappings in the metamodel. The @Any annotation is supported in Hibernate Annotation 3.5.5.
If Hibernate can not support "any" mappings then maybe it could:
* Allow the exclusion of persistent classes by package in the metamodel. I tried this successfully by changing the following code in org.hibernate.ejb.EntityManagerFactoryImpl constructor:
{noFormat}
...
List<PersistentClass> persistentClasses = new ArrayList<PersistentClass>();
while (classes.hasNext()) {
PersistentClass persistentClass = classes.next();
// Hardcode jBPM classes for now, but make tidy with a property like "hibernate.ejb.metamodel.excluded.pkgs"
if (persistentClass.getClassName().startsWith("org.jbpm")) {
continue;
} else {
persistentClasses.add(persistentClass);
}
}
// a safe guard till we are confident that metamodel is wll tested
if (!"disabled".equalsIgnoreCase(cfg.getProperty("hibernate.ejb.metamodel.generation"))) {
this.metamodel = MetamodelImpl.buildMetamodel(persistentClasses.iterator(),
(SessionFactoryImplementor) sessionFactory);}
...
{noFormat}
* Exclude persistent classes having "any" mappings from the metamodel generation.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months
[Hibernate-JIRA] Created: (HHH-6414) CPU spinning, stuck on getResultList()
by Anthony Ogier (JIRA)
CPU spinning, stuck on getResultList()
--------------------------------------
Key: HHH-6414
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6414
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Hibernate Annotations 3.4.0.GA, Hibernate 3.3.1.GA, Hibernate Commons Annotations 3.1.0.GA, Hibernate EntityManager 3.4.0.GA, Seam 2.2.1.Final, JBoss 5.1.0.GA, Windows Server 2008 64bits, Microsoft SQL Server 10.00.4000, JDBC driver: Microsoft SQL Server 2005 JDBC Driver, version: 1.2.2828.100
Reporter: Anthony Ogier
I've got a web application which is well tested (JMeter etc), and suddenly today, 2 of JBoss threads were stuck on a getResultList(), using 100% of the CPU.
Here is the stack for each of the threads :
{noformat}
Thread: http-0.0.0.0-8080-2 : priority:5, demon:true, threadId:156, threadState:RUNNABLE
java.util.HashMap.put(HashMap.java:374)
org.hibernate.engine.StatefulPersistenceContext.addCollection(StatefulPersistenceContext.java:787)
org.hibernate.engine.StatefulPersistenceContext.addUninitializedCollection(StatefulPersistenceContext.java:756)
org.hibernate.type.CollectionType.getCollection(CollectionType.java:642)
org.hibernate.type.CollectionType.resolveKey(CollectionType.java:430)
org.hibernate.type.CollectionType.resolve(CollectionType.java:424)
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
org.hibernate.loader.Loader.doQuery(Loader.java:752)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
org.hibernate.loader.Loader.doList(Loader.java:2228)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
org.hibernate.loader.Loader.list(Loader.java:2120)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
{noformat}
I've seen some similar problems here [JGRP-525|https://issues.jboss.org/browse/JGRP-525] and here [JBMESSAGING-1676|https://issues.jboss.org/browse/JBMESSAGING-1676] and they are talking about concurrency ...
--
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, 10 months
[Hibernate-JIRA] Created: (HHH-6607) Exceptions being hidden in JDBCTransation
by Rich Christy (JIRA)
Exceptions being hidden in JDBCTransation
-----------------------------------------
Key: HHH-6607
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6607
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.7
Environment: The issue happens when the audit schema is different from the primary schema say because of a column change. The database session is rolled back but the exception isn't thrown up to any levels past the notifyLocalSynchsBeforeTransactionCompletion() so any applications needing to recover from database failures cannot - say rolling back application caches.
The way to reproduce this is to drop a column in the aud table for any domain object and try to insert the data
Reporter: Rich Christy
2011-08-24 16:00:15,886 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2242)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:161)
at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:274)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:140)
at org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource.executeBulk(DefaultHibernateExternalDataSource.java:107)
at com.skyroad.motion.transactionmanager.util.TransactionMirrorExternalDataSource.executeBulk(TransactionMirrorExternalDataSource.java:32)
What the code is doing in the exception handling of AuditSync.java (5th line from the bottom in the stack track) is rolling back the transaction as far as the hibernate session is concerned and then unconditionally throwing the exception to the next level. However, the code in notifyLocalSynchsBeforeTransactionCompletion() eating the exception so Gigaspaces isn't aware that it happened. This would explain why the database writes are rolled back but the space isn't.
public void beforeCompletion() {
if (workUnits.size() == 0 && undoQueue.size() == 0) {
return;
}
try {
// see: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178431
if (FlushMode.isManualFlushMode(session.getFlushMode()) || session.isClosed()) {
Session temporarySession = null;
try {
temporarySession = session.getFactory().openTemporarySession();
executeInSession(temporarySession);
temporarySession.flush();
} finally {
if (temporarySession != null) {
temporarySession.close();
}
}
} else {
executeInSession(session);
// Explicity flushing the session, as the auto-flush may have already happened.
session.flush();
}
} catch (RuntimeException e) {
// Rolling back the transaction in case of any exceptions
//noinspection finally
try {
if (session.getTransaction().isActive()) {
session.getTransaction().rollback();
}
} finally {
//noinspection ThrowFromFinallyBlock
throw e;
}
}
}
private void notifyLocalSynchsBeforeTransactionCompletion() {
if (synchronizations!=null) {
for ( int i=0; i<synchronizations.size(); i++ ) {
Synchronization sync = (Synchronization) synchronizations.get(i);
try {
sync.beforeCompletion();
}
catch (Throwable t) {
log.error("exception calling user Synchronization", t);
}
}
}
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months