Filip Nguyen, I'm curious why do you have a need to lock a newly persisted entity? Can you describe your use case?
Also, please attach a runnable test case. You can find a test template at: https://github.com/hibernate/hibernate-test-case-templates