[Hibernate-JIRA] Commented: (HHH-1870) org.hibernate.TransientObjectException: object references an unsaved transient
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870?page=c... ]
Gail Badner commented on HHH-1870:
----------------------------------
I had a bug in how I tweaked the test case for entity manager and can no longer reproduce this.
I believe this was fixed by EJB-221.
> org.hibernate.TransientObjectException: object references an unsaved transient
> -------------------------------------------------------------------------------
>
> Key: HHH-1870
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870
> Project: Hibernate ORM
> Issue Type: Bug
> Environment: Hibernate 3.2.0 RC 2 from SVN tunk 2006/06/30
> Reporter: Sergey Vladimirov
> Assignee: Gail Badner
> Attachments: manytoonelazy.zip, patch.txt
>
>
> JUnit test case shows strange error on commit():
> Session session = sessionFactory.openSession();
> Transaction transaction = session.beginTransaction();
> BeanB beanB = new BeanB();
> beanB.setId(1);
> session.save(beanB);
> beanB = (BeanB) session.load(BeanB.class, 1);
> BeanA beanA = new BeanA();
> beanA.setId(2);
> beanA.setParent((BeanB) session.load(BeanB.class, 1));
> session.save(beanA);
> transaction.commit();
> session.close();
> org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ru.arptek.arpsite.data.manytoonelazy.BeanA.parent -> ru.arptek.arpsite.data.manytoonelazy.BeanB
> at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:273)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:257)
> at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
> at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
> at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
> at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:135)
> at ru.arptek.arpsite.data.manytoonelazy.TestWithoutCache.testFind(TestWithoutCache.java:57)
> 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:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
> 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)
> Temporary patch included. May be it is brokes other issue.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Resolved: (HHH-1870) org.hibernate.TransientObjectException: object references an unsaved transient
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870?page=c... ]
Gail Badner resolved HHH-1870.
------------------------------
Resolution: Cannot Reproduce
Fix Version/s: (was: 4.1.0)
> org.hibernate.TransientObjectException: object references an unsaved transient
> -------------------------------------------------------------------------------
>
> Key: HHH-1870
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870
> Project: Hibernate ORM
> Issue Type: Bug
> Environment: Hibernate 3.2.0 RC 2 from SVN tunk 2006/06/30
> Reporter: Sergey Vladimirov
> Assignee: Gail Badner
> Attachments: manytoonelazy.zip, patch.txt
>
>
> JUnit test case shows strange error on commit():
> Session session = sessionFactory.openSession();
> Transaction transaction = session.beginTransaction();
> BeanB beanB = new BeanB();
> beanB.setId(1);
> session.save(beanB);
> beanB = (BeanB) session.load(BeanB.class, 1);
> BeanA beanA = new BeanA();
> beanA.setId(2);
> beanA.setParent((BeanB) session.load(BeanB.class, 1));
> session.save(beanA);
> transaction.commit();
> session.close();
> org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ru.arptek.arpsite.data.manytoonelazy.BeanA.parent -> ru.arptek.arpsite.data.manytoonelazy.BeanB
> at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:273)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:257)
> at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
> at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
> at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
> at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:135)
> at ru.arptek.arpsite.data.manytoonelazy.TestWithoutCache.testFind(TestWithoutCache.java:57)
> 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:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
> 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)
> Temporary patch included. May be it is brokes other issue.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Reopened: (HHH-1870) org.hibernate.TransientObjectException: object references an unsaved transient
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870?page=c... ]
Gail Badner reopened HHH-1870:
------------------------------
Re-opening because this issue still exists.
> org.hibernate.TransientObjectException: object references an unsaved transient
> -------------------------------------------------------------------------------
>
> Key: HHH-1870
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870
> Project: Hibernate ORM
> Issue Type: Bug
> Environment: Hibernate 3.2.0 RC 2 from SVN tunk 2006/06/30
> Reporter: Sergey Vladimirov
> Assignee: Gail Badner
> Fix For: 4.1.0
>
> Attachments: manytoonelazy.zip, patch.txt
>
>
> JUnit test case shows strange error on commit():
> Session session = sessionFactory.openSession();
> Transaction transaction = session.beginTransaction();
> BeanB beanB = new BeanB();
> beanB.setId(1);
> session.save(beanB);
> beanB = (BeanB) session.load(BeanB.class, 1);
> BeanA beanA = new BeanA();
> beanA.setId(2);
> beanA.setParent((BeanB) session.load(BeanB.class, 1));
> session.save(beanA);
> transaction.commit();
> session.close();
> org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ru.arptek.arpsite.data.manytoonelazy.BeanA.parent -> ru.arptek.arpsite.data.manytoonelazy.BeanB
> at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:273)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:257)
> at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
> at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
> at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
> at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:135)
> at ru.arptek.arpsite.data.manytoonelazy.TestWithoutCache.testFind(TestWithoutCache.java:57)
> 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:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
> 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)
> Temporary patch included. May be it is brokes other issue.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-3967) Great performance improvement for CascadingAction.PERSIST_ON_FLUSH action !!
by Guenther Demetz (JIRA)
Great performance improvement for CascadingAction.PERSIST_ON_FLUSH action !!
----------------------------------------------------------------------------
Key: HHH-3967
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3967
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.3.1
Environment: 3.3.1 GA , SQLServer
Reporter: Guenther Demetz
Sometimes large stateful transactions are unavoidable and especially when having several large persistent collections in dirty state,
flushing becomes gradually more cpu intensive and slowly.
Analizing several stacktraces I detected that the thread most time is executing at the same point in reflection ,
see here a typical stacktrace:
java.lang.Class.isAssignableFrom(Native Method)
sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36)
...
java.lang.reflect.Field.get(Field.java:358)
DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55)
PojoEntityTuplizer(AbstractEntityTuplizer).getPropertyValue(Object, int) line: 300
SingleTableEntityPersister(AbstractEntityPersister).getPropertyValue(Object, int, EntityMode) line: 3609
Cascade.cascade(EntityPersister, Object, Object) line: 172
...
Making further investigations, I saw that:
- CascadingAction.PERSIST_ON_FLUSH requires NoCascadeChecking
- for all kind of properties the noCascade implementation is called
- regarding noCascade implementation checks only properties of type Entity !
public static final CascadingAction PERSIST_ON_FLUSH = new CascadingAction() {
...
public void noCascade(EventSource session, Object child, Object parent, EntityPersister persister, int propertyIndex) {
...
Type type = persister.getPropertyTypes()[propertyIndex];
if ( type.isEntityType() ) {
... check and throw eventually a TransientObjectException
}
}
Thus most property values are retrieved by reflection in vain as they are not of type entity.
With following code addition in org.hibernate.engine.Cascade.java
I was able do avoid most reflection method calls without affecting the behaviour:
org.hibernate.engine.Cascade.java
...
public void cascade(final EntityPersister persister, final Object parent, final Object anything) throws HibernateException {
...
else if ( action.requiresNoCascadeChecking() ) {
// Line:162
// begin Improvement
if (action == CascadingAction.PERSIST_ON_FLUSH) {
Type type = persister.getPropertyTypes()[i];
if ( !type.isEntityType() ) {
// Remark: goes only well as long PERSIST_ON_FLUSH noCascade implementation checks only entities
continue;
}
}
// end Improvement
action.noCascade(
eventSource,
persister.getPropertyValue( parent, i, entityMode ),
parent,
persister,
i
);
...
best regards
Guenther D.
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-6039) jpaEntityName not set when using Hibernate mapping
by JOUFFRE Nelly (JIRA)
jpaEntityName not set when using Hibernate mapping
--------------------------------------------------
Key: HHH-6039
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6039
Project: Hibernate Core
Issue Type: Bug
Components: metamodel, query-criteria
Affects Versions: 3.6.2
Environment: hibernate-(core, entitymanager...)-3.6.2.Final
hibernate-jpa-2.0-api-1.0.0.Final
MySQL 5.1
Spring 3.0.5.RELEASE
Reporter: JOUFFRE Nelly
Attachments: Qualifier.hbm.xml
I'm trying to run the following query
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Qualifier> cq = cb.createQuery(Qualifier.class);
Root<Qualifier> qualifRoot = cq.from(Qualifier.class);
List<Qualifier> results = entityManager.createQuery(cq).getResultList();
The Qualifier class is mapped using Hibernate hbm.xml mapping (see attachement)
The entityManagerFactory is configured using a Spring class
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
</bean>
This Criteria query throws the exception: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: null near line 1, column 29 [select generatedAlias0 from null as generatedAlias0]
The FROM clause, which here is null, is built using the EntityType.jpaEntityName property which value comes from PersistentClass.jpaEntityName property. But this property is never set when context is loaded to build the Metamodel.
Is this property not set because the mapping is an hibernate mapping and not a JPA one ? or is it a bug ?
--
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, 2 months