[Hibernate-JIRA] Commented: (HHH-511) reattach object from same session
by HECTOR JUAREZ (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-511?page=co... ]
HECTOR JUAREZ commented on HHH-511:
-----------------------------------
Hibernate version: 3.1.3
Hi, I thinks this issue is related to another one:
When occurs an exception in a transactional method, the Hibernate session associated seems to be cleared, then when is executed another method with the same session and it tries to save an object that was in the session after the exception ocurrencie, the following exception is triggered: "org.springframework.orm.hibernate3.HibernateSystemException: Found two representations of same collection: org.appfuse.model.User.roles; nested exception is org.hibernate.HibernateException: Found two representations of same collection: <<collectionName>> "
For example:
BeanA
method {
User u = UserDao.getUser(1l);
for (int i=0;i<=1;i++) {
try {
beanB.transactionalMethod(u);
}catch (RuntimeException e) { System.err.println("RuntimeException ="+e);}
}
}
BeanB
transactionalMethod(User u) {
...
userDao.save(u);
}
Assuming that BeanA.method and BeanB.transactionalMethod are transactional and they are using the same Hibernate session, if an exception is triggered in the first call to transactionalMethod, then in the second call that method an exception will be triggered in userDao.save(u).
This exception is the commented above, and it happens because in the first method the hibernate session is cleared at the moment of the rollback, so it seems to have no entities and collections associated, but the exceptions is telling us another thing. This seems contradictory and it looks like Hibernate is not handling correctly this situation.
I was able to avoid this exeptions using session.refresh(u) before saving the user object, but I think that Hibernate should be handling this transparently.
Thanks.
> reattach object from same session
> ---------------------------------
>
> Key: HHH-511
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-511
> Project: Hibernate3
> Type: Bug
> Components: core
> Reporter: Gavin King
> Priority: Minor
> Attachments: reattach-same-session.patch, reattach-same-session.patch
>
>
> http://forum.hibernate.org/viewtopic.php?p=2231400#2231400
> There is a problem when you reattach a collection to the same session that it was previously attached to, after calling clear(). Hibernate checks the collections session reference, at reattach and concludes it is already attached.
--
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
17 years, 7 months
[Hibernate-JIRA] Commented: (HHH-1851) relax special handling of 'id' property
by Gunther Schadow (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1851?page=c... ]
Gunther Schadow commented on HHH-1851:
--------------------------------------
Steve: thanks, Thank you, THANK YOU! Wonderful solution.
> relax special handling of 'id' property
> ---------------------------------------
>
> Key: HHH-1851
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1851
> Project: Hibernate3
> Type: Improvement
> Components: query-hql
> Environment: independent, all versions all databases.
> Reporter: Gunther Schadow
> Assignee: Steve Ebersole
> Fix For: 3.2.2
>
>
> Hibernate has long treated 'id' in a special manner in HQL and Criteria queries. The drawback to this has always been that it effectively means users cannot define non-identifier properties named id and refer to those properties in HQL/Criteria queries.
> Thus, I will change this such that:
> (1) 'id' can still be used to refer to the identifier property, whatever the property's actual name, as long as the entity does not define a non-identitifer property named id.
> (2) if the entity defines a non-identifier property named 'id', using 'id' in HQL or Criteria queries will refer to this non-identifier property; users would need to refer to the identifier property by its actual name.
> FYI, the original reason for this feature was to support entity's which did not define an identifier property at all (users were responsible for managing the ids seperately. That feature was never really recommended and has been deprecated since early in the 3.x development.
--
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
17 years, 7 months
[Hibernate-JIRA] Created: (HHH-2499) incorrect assertion failure relating to generated property values
by Steve Ebersole (JIRA)
incorrect assertion failure relating to generated property values
-----------------------------------------------------------------
Key: HHH-2499
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2499
Project: Hibernate3
Type: Bug
Components: core
Reporter: Steve Ebersole
Assigned to: Steve Ebersole
Fix For: 3.2.3
bad copy/paste job; AbstractEntityPersister:
public void processUpdateGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session) {
if ( !hasInsertGeneratedProperties() ) {
throw new AssertionFailure("no update-generated properties");
}
processGeneratedProperties( id, entity, state, session, sqlUpdateGeneratedValuesSelectString, getPropertyUpdateGenerationInclusions() );
}
should read:
public void processUpdateGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session) {
if ( !hasUpdateGeneratedProperties() ) {
throw new AssertionFailure("no update-generated properties");
}
processGeneratedProperties( id, entity, state, session, sqlUpdateGeneratedValuesSelectString, getPropertyUpdateGenerationInclusions() );
}
--
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
17 years, 7 months
[Hibernate-JIRA] Created: (EJB-261) merge fails to update join table
by Bryan Hunt (JIRA)
merge fails to update join table
--------------------------------
Key: EJB-261
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-261
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.1
Environment: Embedded entity manager 3.2.1 with DB2 or MySQL
Reporter: Bryan Hunt
Priority: Blocker
Doing a merge on an entity with a one to many relationship does not update the join table.
I have the following entities:
@Entity
public class Foo
{
...
@OneToMany(cascade = CascadeType.ALL)
private Set<Bar> bars;
}
@Entity
public class Bar
{
...
}
The following works:
Foo foo = new Foo();
Bar bar = new Bar();
foo.getBars().add(bar);
em.getTransaction().begin();
em.persist(foo); // <<----------------- correctly updates the join table
em.getTransaction().commit();
This also works:
Foo foo = em.find(Foo.class, id);
Bar bar = new Bar();
foo.getBars().add(bar);
em.getTransaction().begin();
em.persist(bar);
em.merge(foo); // <<----------------- correctly updates the join table
em.getTransaction().commit();
When this code executes the new Foo and Bar are persisted to the database, an entry is made into the join table, and all is well.
The following fails:
Foo foo = em.find(Foo.class, id);
Bar bar = new Bar();
foo.getBars().add(bar);
em.getTransaction().begin();
em.merge(foo); // <<----------------- does not update the join table
em.getTransaction().commit();
When this code executes, the new Bar is persisted to the database, but the join table is not updated.
--
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
17 years, 7 months