问题
use Service layer to persist data into database. But the Unit Test does not have this problem. I turn on debug and check the log file carefully. In the place where data should inert into database, I find the information: "delaying identity-insert due to no transaction in progress"
回答1:
the issue was due to @Transaction and @Autowire
my generic dao was autowired and when we @Transaction it is unable to wrap my service class by transaction proxy class thus .It executes without saving data and without giving any error except the message as "delaying identity-insert due to no transaction in progress".
I removed the autowire and injected manually the genric dao object and it starts working.
来源:https://stackoverflow.com/questions/9774384/delaying-identity-insert-due-to-no-transaction-in-progress