[
https://issues.apache.org/jira/browse/RAVE-845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13492548#comment-13492548
]
Viknes B commented on RAVE-845:
-------------------------------
I spent some more time looking into this and I think we are in a position to
use only queries to delete the associations.
The reason is
1) If we have a field called 'friends' in JpaPerson that maps to the items in
JpaPersonAssociation, it would not make much sense when we do a
person.getFriends() because whether a particular user is friend or not is
defined by the status of the association and there is now way to specify it
when we are joining tables using annotations.
And yet one more problem would be, when a friend relationship is established,
we insert 2 rows into JpaPersonAssociation. One is from A to B and other is
from B to A. Having a single field of JpaPerson associated to a column in
JpaPersonAssociation would remove the A to B record but not the B to A
one(which is again a problem).
2) Other thing that can be done is having 2 new fields called 'followerOf' and
'followedBy' in JpaPerson which would map to each of the columns in
JpaPersonAssociation, and then when a person is deleted, the corresponding
association would be deleted. But the downside is, we dont have the concept of
followerof or followedby anywhere in Rave and this would just add more
confusion.
So the only way that seems plausible to me is using a query to delete the
associations when a user is deleted. If no one has any problem with it, i can
go ahead and do it.
> Cannot delete a user which has one or more friend associations
> --------------------------------------------------------------
>
> Key: RAVE-845
> URL: https://issues.apache.org/jira/browse/RAVE-845
> Project: Rave
> Issue Type: Bug
> Affects Versions: 0.17
> Reporter: Ate Douma
> Priority: Blocker
> Fix For: 0.18
>
>
> As reported on the dev@ list:
>
> On 11/05/2012 02:20 PM, Franklin, Matthew B. wrote:
> > I went through the release and everything looks good except that I can't
> > seem to delete users. I get the following exception with the demo binary
> > as well as the built source:
> >
> > [WARNING] [talledLocalContainer] SEVERE: Servlet.service() for servlet
> > dispatcher threw exception
> > [WARNING] [talledLocalContainer]
> > org.apache.rave.persistence.impl.TranslatedH2Exception: Unknown Database
> > Error
> > [WARNING] [talledLocalContainer] at
> > org.apache.rave.persistence.jpa.impl.H2OpenJpaDialect.translateExceptionIfP
> > ossible(H2OpenJpaDialect.java:60)
> > [WARNING] [talledLocalContainer] at
> > org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionMa
> > nager.java:516)
> > [WARNING] [talledLocalContainer] at
> > org.springframework.transaction.support.AbstractPlatformTransactionManager.
> > processCommit(AbstractPlatformTransactionManager.java:754)
> > [WARNING] [talledLocalContainer] at
> > org.springframework.transaction.support.AbstractPlatformTransactionManager.
> > commit(AbstractPlatformTransactionManager.java:723)
> >
> Followed up by:
> On 11/05/2012 04:47 PM, Franklin, Matthew B. wrote:
> > I confirmed that I was working with a clean database and dug a little
> > deeper to find that it only occurs when you are deleting a user that has
> > one or more associations. The exact exception is as follows:
> >
> > Referential integrity constraint violation: "CONSTRAINT_43:
> > PUBLIC.PERSON_ASSOCIATION FOREIGN KEY(FOLLOWEDBY_ID) REFERENCES
> > PUBLIC.PERSON(ENTITY_ID) (3)"; SQL statement:
> > DELETE FROM person WHERE entity_id = ? [23503-167] {prepstmnt 1230081703
> > DELETE FROM person WHERE entity_id = ? [params=?]} [code=23503,
> > state=23503]
> >
> and:
> On 11/05/2012 04:57 PM, Chris Geer wrote:
> > Ok, this probably makes sense. Since we did the model split, I bet JPA no
> > longer enforces referential integrity. We probably need to add in business
> > level checks for related entities.
> and:
> On 11/05/2012 05:09 PM, Ate Douma wrote:
> > Confirmed. I just tried this with a mysql database and hit the same error.
> >
> > As Chris mentioned on his rely, most likely the referential integrity no
> > longer
> > is 'managed' through JPA after the model split. Which means this might not
> > be
> > the only case behavior is broken.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira