Greetings! I am trying to make use of the above mentioned (@PersistenceProperty) annotation however all my attempts had failed. I tried to pinpoint the issues, but I couldn't,
Maybe I am missing something about this annotation, but I am testing it in a brand new project on a separate PC. The test case is the following:
?? @Repository @Transactional public class PhoneBookRepo {
@PersistenceContext(unitName = "default", properties = {@PersistenceProperty(name = "org.hibernate.flushMode", value = "MANUAL") }) private EntityManager em; public void test() { FlushModeType fm = em.unwrap(Session.class).getFlushMode(); } } ??
I had tried with "hibernate.flushMode", "spring.jpa.properties.hibernate.flushMode" etc.
I had tried with "hibernate.show_sql" ,"hibernate.generate_statistics","hibernate.jdbc.batch_size" with "hibernate.order_inserts" and the variations with "spring.jpa.properties" or "org" as prefix.
These are my application.properties spring.datasource.url=jdbc:mysql://localhost:3306/Hibernate?useSSL=false&rewriteBatchedStatements=true spring.datasource.username=user spring.datasource.password=pass spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect spring.jpa.database=mysql spring.datasource.driver-class-name=com.mysql.jdbc.Driver
I tried with flushMode = COMMIT, it is still set as AUTO.
Honestly what I am trying to achieve is set "hibernate.jdbc.batch_size" and "hibernate.order_inserts" for this particular @Repository. I have already made it work using spring.datasource.url=jdbc:mysql://localhost:3306/Hibernate?useSSL=false&rewriteBatchedStatements=true&profileSQL=true&logger=com.mysql.jdbc.log.Slf4JLogger spring.jpa.properties.hibernate.jdbc.batch_size = 50 spring.jpa.properties.hibernate.order_inserts = true
But I cant make it work with @PersistenceProperty annotation. At least to my understanding this is stated in the documentation. |
|