-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testcase for ebean with circular dependences #1723
Conversation
1. While the javax.persistance api discourages the use of bidirectional cascades, it does not prohibit them. They're very useful and natural if you think of the database as a graph instead of a tree. test case 1 (testCircularCascade) tests this. 2. Second test case fetches the child, but saves the parent. If used like that, the child will not have it's changes saved.
return convertFromTimestamp(dateTimeParser.parse(jsonDateTime)); | ||
Instant instant = Instant.parse(jsonDateTime.replace(" ", "T")); | ||
Timestamp ts = Timestamp.from(instant); | ||
return convertFromTimestamp(ts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not happy with this change
- why do you need to replace
T
? (btw when replacing single characters it is better to usereplace(' ', 'T')
) - the change makes the dateTimeParser.parse method obsolete. So it would be better to change the 'parse' implementation.
What was the problem here? I assume, the precision of fractions of the DateTimeParser. Newer java versions (11+) probable needs up to 9 digits: `yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'
@rbygrave I think it would be a good idea to refactor the DateTimeParser, so that it uses Instant.parse instead of SimpleDateFormat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4cb678f
to
3bf9dd6
Compare
Nice tests. I should get to them shortly (tomorrow night). |
@rbygrave I can make these test cases work by moving the diff --git a/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java b/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
index 0d02a49ef..3d8134b7b 100644
--- a/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
+++ b/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
@@ -546,10 +546,6 @@ public final class DefaultPersister implements Persister {
}
request.flagUpdate();
try {
- if (request.isPersistCascade()) {
- // save associated One beans recursively first
- saveAssocOne(request);
- }
if (request.isDirty()) {
request.executeOrQueue();
@@ -558,6 +554,11 @@ public final class DefaultPersister implements Persister {
logger.debug(Message.msg("persist.update.skipped", request.getBean()));
}
+ if (request.isPersistCascade()) {
+ // save associated One beans recursively first
+ saveAssocOne(request);
+ }
+
if (request.isPersistCascade()) {
// save all the beans in assocMany's after
saveAssocMany(request); |
Note that there is not a fix for testFetchChildModifyChildSaveParent() yet. This test just marked with |
Two failing test cases.
cascades, it does not prohibit them. They're very useful and natural
if you think of the database as a graph instead of a tree.
test case 1 (testCircularCascade) tests this.
that, the child will not have it's changes saved, even with cascade = ALL.