Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@csokol
Copy link
Contributor

@csokol csokol commented Jun 10, 2015

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identation ):

@leocwolter
Copy link
Contributor

Well, as I said at the other pr, I prefer logic deletion over physical deletion. Its easier to implement and you can always rollback

@csokol
Copy link
Contributor Author

csokol commented Jun 13, 2015

@leocwolter
Copy link
Contributor

Even this query?

session.createSQLQuery("delete from Answer_Comments where comments_id=:id")
         .setParameter("id", comment.getId()).executeUpdate();

@csokol
Copy link
Contributor Author

csokol commented Jun 14, 2015

Well, in this case I had to delete the data from the relationship table because hibernate was not so smart to ignore logically deleted comments when querying answers/questions joined with its comments. I can try to add where comment.deleted = false everywhere, but I think we would need to always remember to do that on complex queries. What do you think?

@leocwolter
Copy link
Contributor

Well, I don't know if it will be hard or not to ignore all of them, but if we used left joins they should be ignored automatically if their relationships are, right?
I mean, the idea of using logical deletion is that we can undo the deletion if we want, but if you delete the relation table lines it would be much harder

@csokol
Copy link
Contributor Author

csokol commented Jun 17, 2015

They can't be ignored on left joins since the row still exists after deletion and hibernate is not smart enough to add where deleted=false automatically for joins. I'll try to track all the queries we are joining the comments and add this condition but I still think this will be ugly since we we'll need to remember to add this predicate forever.

@csokol
Copy link
Contributor Author

csokol commented Jun 22, 2015

Hi Leo, I removed that query from CommentDAO and added the logic to ignore deleted questions. I'm merging this one!

csokol added a commit that referenced this pull request Jun 22, 2015
@csokol csokol merged commit 2444faf into caelum:master Jun 22, 2015
@csokol csokol deleted the deleting-users branch June 22, 2015 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants