Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

#22 JPA CRUD recipe #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

#22 JPA CRUD recipe #61

wants to merge 2 commits into from

Conversation

ihostage
Copy link
Contributor

No description provided.

@ihostage ihostage mentioned this pull request Dec 28, 2018
Copy link
Contributor

@ignasi35 ignasi35 left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

}
});
};
}
Copy link
Contributor

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.

Copy link
Contributor Author

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
}
}
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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" />
Copy link
Contributor

Choose a reason for hiding this comment

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

cassandra/datastax 😅

Copy link
Contributor Author

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 {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

4 participants