[
http://opensource.atlassian.com/projects/hibernate/browse/EJB-260?page=all ]
Emmanuel Bernard resolved EJB-260:
----------------------------------
Resolution: Cannot Reproduce
I've got something different, which is expected since there is no cascade
Hibernate: select customergr0_.customer_group_id as customer1_1_0_, customergr0_.name as
name1_0_ from customer_group customergr0_ where customergr0_.customer_group_id=?
Hibernate: insert into customer_group (name) values (?)
Hibernate: select customer0_.customer_id as customer1_0_0_ from customer customer0_ where
customer0_.customer_id=?
javax.persistence.EntityNotFoundException: Unable to find Customer with id CIDD803997
at
org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:107)
at
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:145)
at
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
at org.hibernate.type.EntityType.resolve(EntityType.java:379)
at org.hibernate.type.EntityType.replace(EntityType.java:259)
at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:425)
at org.hibernate.type.CollectionType.replace(CollectionType.java:481)
at org.hibernate.type.AbstractType.replace(AbstractType.java:153)
at org.hibernate.type.TypeFactory.replaceAssociations(TypeFactory.java:530)
at
org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:366)
at
org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:195)
at
org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:240)
at
org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
at
org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:227)
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
org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:237)
at $Proxy13.merge(Unknown Source)
at TestCustomerGroup.testMergeOnlyNewCustomerWithDetachGroup(TestCustomerGroup.java:34)
at TestCustomerGroup.main(TestCustomerGroup.java:95)
OneToMany relationship not persiting merges
-------------------------------------------
Key: EJB-260
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-260
Project: Hibernate Entity Manager
Type: Bug
Versions: 3.2.1
Environment: MySQL 5.0x
Reporter: Chadwick Baatz
Priority: Blocker
Attachments: TestProject.zip
I am having problems with the merging of a detached object that has changed. The
unidirectional OneToMany relationship is being updated in the Hibernate Context, but that
update is not being persisted to the database. I've been able to prove that the
Hibernate layer works correctly when either:
1. The object is not detached and I perform a persist
2. The object is detached I perform a merge before any changes, then persist after all
changes have been made to the object.
However, if I have a detached object with modifications to the manged one and I perform a
merge those changes are done to the managed object in the Hibernate Context, but the
database statement is never fired to make the change in the database. Worse yet, any
changes merged in this way are not updated on subsequent persist calls.
I've attached a sample project with test code that you can use to recreate the
problem. You the SQL statements below to populate the database and you'll have to set
up the connection in the persistence.xml file.
SQL Statements:
Create table customer (
customer_id Varchar(100) NOT NULL,
UNIQUE (customer_id),
Primary Key (customer_id)) ENGINE = InnoDB;
Create table customer_group (
customer_group_id Int UNSIGNED NOT NULL AUTO_INCREMENT,
name Varchar(250),
Primary Key (customer_group_id)) ENGINE = InnoDB;
Create table customer_group_customer (
customer_group_id Int UNSIGNED NOT NULL,
customer_id Varchar(100) NOT NULL,
Primary Key (customer_group_id,customer_id)) ENGINE = InnoDB;
Alter table customer_group_customer add Foreign Key (customer_id) references customer
(customer_id) on delete restrict on update restrict;
Alter table customer_group_customer add Foreign Key (customer_group_id) references
customer_group (customer_group_id) on delete restrict on update restrict;
Create table customer (
customer_id Varchar(100) NOT NULL,
UNIQUE (customer_id),
Primary Key (customer_id)) ENGINE = InnoDB;
Create table customer_group (
customer_group_id Int UNSIGNED NOT NULL AUTO_INCREMENT,
name Varchar(250),
Primary Key (customer_group_id)) ENGINE = InnoDB;
Create table customer_group_customer (
customer_group_id Int UNSIGNED NOT NULL,
customer_id Varchar(100) NOT NULL,
Primary Key (customer_group_id,customer_id)) ENGINE = InnoDB;
Alter table customer_group_customer add Foreign Key (customer_id) references customer
(customer_id) on delete restrict on update restrict;
Alter table customer_group_customer add Foreign Key (customer_group_id) references
customer_group (customer_group_id) on delete restrict on update restrict;
--
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