-
Notifications
You must be signed in to change notification settings - Fork 34
#22 JPA CRUD recipe #61
base: master
Are you sure you want to change the base?
Conversation
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 think this recipe has a bit of noise code (e.g. validate
methods in ServiceImpl, or test more extense than necessary).
The purpose of this recipe is to demonstrate how to use JPA in Lagom to do CRUD. The most important detail is to ensure all blocking ops happen on a separate thread pool and also to demonstrate transactionality and the excess code makes it hard to locate this two details.
This recipe demonstrates, how you can use Play's [JPA API](https://www.playframework.com/documentation/2.6.x/JavaJPA) | ||
for implement Lagom service with CRUD-oriented persistence. | ||
|
||
## About service |
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.
This recipe is relying on a custom library which wraps Play JPA and makes it easier to use. It'd be good if this was mentioned upfront.
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.
Added the link to the library and some words in readme.
} | ||
}); | ||
}; | ||
} |
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 sure update
and delete
are transactional.
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 afraid I did not understand 😞
thread-pool-executor { | ||
fixed-pool-size = 10 | ||
} | ||
} |
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.
This is the most important aspect of the recipe. All blocking code must run on a separate dispatcher which must be a thread pool (not a fork join!) as you demo here. It'd be great if that important details was documented here or in the README.md.
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.
Added info about separate dispatcher (here and in the README).
If this is not enough, let me know 😉
# --- !Downs | ||
|
||
DROP TABLE ENTITY_PART; | ||
DROP TABLE ENTITY; |
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 don't think it's a good idea to have this file on the evolutions/default
folder.
Evolutions don't work in Lagom (neither dev mode nor production) so I'd rather not mislead people into thinking otherwise. I think this file should be placed in src/main/sql
and not even use the --- !Ups
/--- !Downs
syntax.
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.
Evolutions work fine in Lagom 😉We use Evolutions in production for our services.
This recipe not use the setting hibernate.hbm2ddl.auto
in persistence.xml (none
default value). Without Evolutions, this recipe would not be passed any test and would not be running 😄
</appender> | ||
|
||
<logger name="org.apache.cassandra" level="ERROR" /> | ||
<logger name="com.datastax.driver" level="WARN" /> |
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.
cassandra
/datastax
😅
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.
🙃 Removed 😂
@Test | ||
@SuppressWarnings("unchecked") | ||
@DisplayName("correct entity should be create successfully") | ||
void shouldCreateEntity() throws InterruptedException, ExecutionException, TimeoutException { |
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.
JUnit 5! Oh yeah!
It's so good to see people adopting and demoing it! +100
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.
👍
No description provided.