[ 
https://issues.apache.org/jira/browse/RAVE-845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13491184#comment-13491184
 ] 

Viknes B commented on RAVE-845:
-------------------------------

As a quick solution to this problem, I guess we could write the following query 
to find the associations of a particular user by username and delete all the 
JpaPersonAssociations while deleting a particular JpaPerson. 
"select a from JpaPersonAssociation a where a.follower.username = :username or 
a.followedby.username = :username".
A long term solution would be to find a way to add a meaningful 2 way 
association between JpaPersonAssociation and JpaPerson and delete it through 
JPA cascade delete.
                
> 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

Reply via email to