[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
Hi there, I haven't been able to solve this same problem (deleted entity passed to persist exception when deleting a OneToMany with cascade all relation(). You say you just have to refresh the parent, but you were saying that you delete the parent and you expect the children to be deleted. If you delete the parent, how do you refresh it? (I get Not managed entity if I try to em.refresh() it) Thanks for any help, Ignacio View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4071781#4071781 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4071781 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
fhh wrote : Another problem might be that your entityManager is not in sync with the database. You were right. I simply had to refresh the parent and then hibernate could delete all references. So it's working now. Conclusion: Hibernate does the cascading delete itself and does not use database features for that. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4035656#4035656 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4035656 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
I'm facing a similar problem with child entities not being deleted with their parents. The exception I see is javax.persistence.EntityNotFoundException: deleted entity passed to persist, and it looks like the entity manager is trying to persist the child entities with null references to the parent. I have CascadeType.ALL set on that relationship. I'd be very disappointed to learn that manual deletion of child entities or database-level cascades were necessary, as the whole point of the JPA cascade functionality is to avoid that. But, I don't have a better answer yet. (BTW, I'm also on jboss 4.0.5 and postgres 8.1; it's bizarre that you're hitting a constraint violation and I'm not even getting that far). View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4035143#4035143 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4035143 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
When I said the entity manager deletes the children manually I did not mean to say that _you_ as developer have to do it. What I meant to say is that instead of using on delete cascade on the constraint the entity manager might send a delete statement for every child to the database. Regards Felix View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4035176#4035176 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4035176 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
fhh wrote : Have you looked up which entity the error message refers to and to which constraint? | | Another problem might be that your entityManager is not in sync with the database. | | | Regards | | Felix Hi Felix, the error message refers to member sender of entity ChatMessage. I looked up the constraint in my database and there it says: | CONSTRAINT fk278c74e4b6f3dc65 FOREIGN KEY (sender) | REFERENCES users (id) MATCH SIMPLE | ON UPDATE NO ACTION ON DELETE NO ACTION, | I wonder about ON DELETE NO ACTION. Shouldn't it be ON DELETE CASCADE? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034694#4034694 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034694 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
Hi! I've just altered the table to enable cascading: | CONSTRAINT fk278c74e4b6f3dc65 FOREIGN KEY (sender) | REFERENCES users (id) MATCH SIMPLE | ON UPDATE NO ACTION ON DELETE CASCADE, | And now deleting users works fine, but why is the schema not created automatically this way? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034713#4034713 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034713 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
anonymous wrote : | And now deleting users works fine, but why is the schema not created automatically this way? | I'm not sure whether javax persitence uses the on delete cascade functionality of the underlying database or whether the entitymanager will manually delete ferenced entities. Regards Felix View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034802#4034802 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034802 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
fhh wrote : anonymous wrote : | | And now deleting users works fine, but why is the schema not created automatically this way? | | | | I'm not sure whether javax persitence uses the on delete cascade functionality of the underlying database or whether the entitymanager will manually delete ferenced entities. | | Regards | | Felix Does anybody here know these details and can me tell what to do now? Manually altering the database after deployment cannot be a real solution. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034863#4034863 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034863 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
Nobody an idea? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4033908#4033908 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4033908 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
Hi!! I'm not sure about this. But I think I've read that you cannot specify booth name and referenceColumn when using the JoinColumn annotation. Try to just use the name attribute. //Oskar View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034042#4034042 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034042 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
Thanks for your reply. I tried it out. I removed the name and/or the referencedColumn, but it didn't work. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034270#4034270 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034270 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Entity relationship and remove operations
Have you looked up which entity the error message refers to and to which constraint? Another problem might be that your entityManager is not in sync with the database. Regards Felix View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034341#4034341 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034341 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user