[Hibernate-JIRA] Created: (HHH-4462) Hibernate is trying to load collections it isn't supposed to when using bean validation event listener
by Ken Egervari (JIRA)
Hibernate is trying to load collections it isn't supposed to when using bean validation event listener
------------------------------------------------------------------------------------------------------
Key: HHH-4462
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4462
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.2
Environment: Also says the same thing in 3.5.0.Beta-1
Reporter: Ken Egervari
I'm getting a weird error that only occurs when the bean validation event listener is being activated. If I remove the constraint annotation, I don't have a problem - the test passes. This is the exception I get:
ERROR AssertionFailure:45 - 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: collection [jawbs.domain.jobseeker.JobSeeker.watchedJobs] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:228)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:356)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at jawbs.DatabaseTests.flush(DatabaseTests.java:89)
Here is the code that causes the exception - at the call to sessionFactory.getCurrentSession().flush() (which just happens to be flush() in this test method).
@Test
public void jobSeekersCanSaveAPreviousResumeWithTheSameName() {
JobSeekerResume resume = ( JobSeekerResume ) resumeDao.find( 1 );
resume.setDescription( "new desc." );
resumeDao.save( resume );
flush();
jdbcMap = simpleJdbcTemplate.queryForMap(
"select * from resume where resume_id = ?", resume.getId() );
assertEquals( resume.getDescription(), jdbcMap.get( "DESCRIPTION" ) );
}
I don't think the mappings are really that important. Basically, "JobSeekerResume" contains a "JobSeeker", and JobSeeker contains many collections. Every time I run the test, I randomly get this error for any of the collections within the JobSeeker object. In the exception above, it just happened to be the "watchedJobs" collection property. It changes every time I run the test.
Now, the reason this problem is happening is that my constraint also hits the database. The constraint asks the sessionFactory to open a session, start a transaction, execute a query, close the transaction and then finally close the session. I've also tried it with a StatelessSession instead, but the same problem persists. Here is the query:
select count(*) from JobSeekerResume where name = :name and id != :id and jobSeeker.id = :jobSeekerId
Here is the constraint code:
public boolean isValid( DomainObject domainObject, ConstraintValidatorContext context ) {
BeanWrapper beanWrapper = new BeanWrapperImpl( domainObject );
SessionFactory sessionFactory =
( SessionFactory ) ApplicationContextProvider.getBean( "sessionFactory" );
if( enabled && sessionFactory != null ) {
logger.debug( "Enabled - Validating constraint with: " );
logger.debug( hql );
StatelessSession session = sessionFactory.openStatelessSession();
Transaction tx = session.beginTransaction();
Query query = session.createQuery(
HqlParser.removePeriodsFromParameterNames( hql )
);
for( String parameterName : HqlParser.getParameterNames( hql ) ) {
query.setParameter(
HqlParser.removePeriodsFromParameterName( parameterName ),
beanWrapper.getPropertyValue( parameterName )
);
}
boolean result = (Long) query.uniqueResult() == 0;
logger.debug( "isValid is returning: " + result );
tx.commit();
session.close();
return result;
}
return true;
}
Now, this query is 100% fine in isolation... and by using logging information, everything is working - the query, the sessions are getting closed, etc. as well.
It is curious though that if I disable this constraint, the test passes. With this constraint... it does not.
Is this a problem with my constraint? With the bean validation event listener?
I'd appreciate any help... and if it is a bug, that it gets fixed. Thank you.
--
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
14 years, 9 months
[Hibernate-JIRA] Commented: (HHH-1012) Index not created by SchemaUpdate
by Pedro Alves (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1012?page=c... ]
Pedro Alves commented on HHH-1012:
----------------------------------
Just bumped into this :(
Very annoying. Seems also a dup of HB-1458
My vote is here
> Index not created by SchemaUpdate
> ---------------------------------
>
> Key: HHH-1012
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1012
> Project: Hibernate Core
> Issue Type: New Feature
> Components: metamodel
> Affects Versions: 3.2.5
> Environment: Windows XP, MySQL/PostgreSQL
> Reporter: Xavier Farret
> Assignee: Steve Ebersole
> Priority: Minor
> Fix For: 3.2.x, 3.3.x, 3.5
>
> Attachments: Indexes.patch
>
>
> i'm using an hbm.xml as describe below and the 'hibernate.hbm2ddl.auto' is egal to update.
> <class table="featurestat" name=".....">
> <id name="id" type="long" column="idFeatureStat">
> <generator class="increment"/>
> </id>
> <properties name="fsUniqueValue" unique="true">
> ....
> </properties>
> <property name="frequency" .../>
> <property name="idFatherFeature" index="FeatStatDocExtSectFeat" not-null="true" type="long" column="..."/>
> ....
> </class>
> Indexes for pk or unique key are well created, but the index explicity named 'FeatStatDocExtSectFeat' is never created. If i put the property 'hibernate.hbm2ddl.auto' in the cfg.xml as 'create' the index is created. But in my case i have to set my property 'hibernate.hbm2ddl.auto' to update.
--
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
14 years, 9 months
[Hibernate-JIRA] Created: (ANN-798) TransactionTest is leaving some transaction opened after its execution, causing DB2 to hang
by Juraci Paixao Krohling (JIRA)
TransactionTest is leaving some transaction opened after its execution, causing DB2 to hang
-------------------------------------------------------------------------------------------
Key: ANN-798
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-798
Project: Hibernate Annotations
Issue Type: Bug
Environment: DB2 and Annotations branch v3_2_1_GA_CP
Reporter: Juraci Paixao Krohling
The first test to be executed after TransactionTest hangs forever, waiting for some transaction to be closed.
The line 32 for org.hibernate.test.annotations.TestCase is the place where it hangs, so, you can add "getSessions().close()" to the end of testTransactionCommit from TransactionTest to simulate this problem without running multiple tests.
As far as I could find, the transaction is not explicit and is "opened" in the last block of assertions in the test testTransactionCommit, between lines 43 and 50 of TransactionTest. If this part is commented out (or skipped) for DB2, everything else works fine.
I suspect this is a problem with the test case, and that this last part of the test should be skipped for DB2, but as I could not find the exact root cause of this failure, I'll leave this as a bug for now.
--
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
14 years, 9 months
[Hibernate-JIRA] Created: (HHH-4458) WebSphereExtendedJTATransactionLookup doesn't correctly identify a rollback to AbstractEntityManagerImpl
by Mike Youngstrom (JIRA)
WebSphereExtendedJTATransactionLookup doesn't correctly identify a rollback to AbstractEntityManagerImpl
--------------------------------------------------------------------------------------------------------
Key: HHH-4458
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4458
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.7
Reporter: Mike Youngstrom
I'm using WebSphereExtendedJTATransactionLookup with Hibernate EntityManager in Websphere 6.1. I noticed that if I have a transaction rollback it does not clear my PersistenceContext. I traced problem down to WebSphereExtendedJTATransactionLookup.TransactionAdapter.registerSynchronization.
It appears that when handling afterCompletion of a rollback websphere is passing args[2]=false. The adapter is translating that to "STATUS_UNKNOWN" which is not identified by AbstractEntityManagerImpl.joinTransaction()'s Synchronization as a rollbackable status as it only looks for STATUS_ROLLEDBACK.
I wonder if WebSphereExtendedJTATransactionLookup should be detecting args[2]=false as STATUS_ROLLEDBACK instead of STATUS_UNKNOWN. I made that change locally and it appears to work.
To patch I simply changed WebSphereExtendedJTATransactionLookup:138 to STATUS_ROLLEDBACK.
--
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
14 years, 9 months
[Hibernate-JIRA] Created: (HHH-3621) Assertion failure in MigrationTest
by Juraci Paixao Krohling (JIRA)
Assertion failure in MigrationTest
----------------------------------
Key: HHH-3621
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3621
Project: Hibernate Core
Issue Type: Bug
Components: testsuite
Affects Versions: 3.3.x
Environment: Oracle 9i/Oracle 10g/Sybase 12/MySQL and Branch_3_3
Reporter: Juraci Paixao Krohling
The test testSimpleColumnAddition (org.hibernate.test.schemaupdate.MigrationTest) fails due to an assertion failure.
It seems something related to the environment, but as the tests are running without changes from SVN, it needs to be fixed. The tests are running using to the profiles specified in the "testsuite" maven configuration file.
Stack trace:
junit.framework.AssertionFailedError: expected:<0> but was:<1>
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.failNotEquals(Assert.java:277)
at junit.framework.Assert.assertEquals(Assert.java:64)
at junit.framework.Assert.assertEquals(Assert.java:195)
at junit.framework.Assert.assertEquals(Assert.java:201)
at org.hibernate.test.schemaupdate.MigrationTest.testSimpleColumnAddition(MigrationTest.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.hibernate.junit.UnitTestCase.runBare(UnitTestCase.java:63)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
--
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
14 years, 9 months
[Hibernate-JIRA] Created: (HHH-4456) Hibernate gives a Javaassist object rather than the real object that I need in a subclass mapping
by Ken Egervari (JIRA)
Hibernate gives a Javaassist object rather than the real object that I need in a subclass mapping
-------------------------------------------------------------------------------------------------
Key: HHH-4456
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4456
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: 3.3.1 ga, hsqldb/mysql
Reporter: Ken Egervari
I have an interesting mapping where the parent class is sub classed and is mapped as such... and it contains an object that is also sub classed. Because java doesn't have multiple inheritance, I do this to avoid a wacky exponentially complex inheritance hierarchy. I would say this is pretty normal domain architecture for the type of problem.
Now, on the inner object, Hibernate is doing the mapping just fine, but when I pull it from the database and cast it, it throws an example.
{code}
java.lang.ClassCastException: jawbs.domain.application.questiontype.QuestionType_$$_javassist_7 cannot be cast to jawbs.domain.application.questiontype.MultipleChoiceType
at jawbs.dao.QuestionDaoTest.findJobApplicationQuestion(QuestionDaoTest.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
...
{code}
The code is just a test case:
{code}
@Test
public void findJobApplicationQuestion() {
JobApplicationQuestion question = ( JobApplicationQuestion )
questionDao.find( 2 );
// THIS IS WHERE THE PROGRAM BOMBS
MultipleChoiceType type = ( MultipleChoiceType ) question.getType();
assertEquals( "What is the namespace for jawbs in JS?", question.getText() );
assertEquals( 1, question.getJob().getId() );
assertEquals( 3, type.getCorrectOption().getId() );
}
{code}
And the mapping is as follows. There are two entities, one containing another... and both entities are being sub classed.
{code?xml}
<class name="jawbs.domain.application.Question" table="question" abstract="true">
<id name="id" column="question_id" type="long">
<generator class="native"/>
</id>
<discriminator column="application_type" type="string"/>
<property name="text" type="text" />
<many-to-one name="type" class="jawbs.domain.application.questiontype.QuestionType"
column="question_type_id" />
<subclass name="jawbs.domain.application.JobApplicationQuestion" discriminator-value="JOB">
<many-to-one name="job" class="jawbs.domain.job.Job"
column="job_id"/>
</subclass>
<subclass name="jawbs.domain.application.ScholarshipApplicationQuestion" discriminator-value="SCHOLARSHIP">
<many-to-one name="employer" class="jawbs.domain.employer.Employer"
column="employer_id"/>
</subclass>
</class>
<class name="jawbs.domain.application.questiontype.QuestionType" table="question_type" abstract="true">
<id name="id" column="question_type_id" type="long">
<generator class="native"/>
</id>
<discriminator column="type" type="string"/>
<many-to-one name="question" class="jawbs.domain.application.Question"
column="question_id"/>
<subclass name="jawbs.domain.application.questiontype.TrueFalseType" discriminator-value="TRUE_FALSE">
<property name="correctChoice" column="correct_choice" />
</subclass>
<subclass name="jawbs.domain.application.questiontype.MultipleChoiceType" discriminator-value="MULTIPLE_CHOICE">
<many-to-one name="correctOption" class="jawbs.domain.application.questiontype.MultipleChoiceOption"
column="correct_option_id"/>
</subclass>
<subclass name="jawbs.domain.application.questiontype.OpenEndedType" discriminator-value="OPEN_ENDED">
</subclass>
</class>
{code}
I'd appreciate any assistance. I suspect this is a bug, or maybe I configured it wrong. The documentation doesn't really include examples like this, so I dunno what to do to fix it.
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
14 years, 9 months