java ee - Openjpa slice with spring issue -


i have been trying configure openjpa-slice spring boot. configuration shared follows:

@configuration public class datasourceconfiguration extends jpabaseconfiguration{  @bean(name = "slice1") public datasource datasource() {     jndidatasourcelookup datasourcelookup = new jndidatasourcelookup();     datasource datasource = datasourcelookup.getdatasource("java:/mysqlxads");     return datasource; }  @bean(name = "slice2") public datasource datasource2() {     jndidatasourcelookup datasourcelookup = new jndidatasourcelookup();     datasource datasource = datasourcelookup.getdatasource("java:/mysqlxads2");     return datasource; }  @override protected map<string, object> getvendorproperties() {     hashmap<string, object> map = new hashmap<string, object>();     return map; }  public localcontainerentitymanagerfactorybean entitymanagerfactory(         entitymanagerfactorybuilder builder) {     map<string, object> properties = new hashmap<string, object>();      properties.put("openjpa.brokerfactory", "slice");     properties.put("openjpa.slice.names", "one, two");     properties.put("openjpa.slice.master", "two");     properties.put("openjpa.slice.lenient", "false");     properties.put("openjpa.slice.connectiondrivername", "com.mysql.jdbc.driver");     properties.put("openjpa.slice.one.connectionfactoryname", "java:/mysqlxads");     properties.put("openjpa.slice.two.connectionfactoryname", "java:/mysqlxads2");     properties.put("openjpa.slice.distributionpolicy", "com.services.sample.configuration.userdistributionpolicy");     properties.put("openjpa.slice.transactionpolicy" , "xa");     properties.put("openjpa.transactionmode" , "managed");     properties.put("openjpa.connectionfactorymode", "managed");     properties.put("openjpa.jdbc.dbdictionary", "mysql");     properties.put("openjpa.log","defaultlevel=warn, runtime=info, tool=info, sql=trace");      return builder             .datasource(datasource()).jta(true)             .properties(properties)             .packages("com.services.sample.domain.entity")             .persistenceunit("sample")             .build(); }  @override protected abstractjpavendoradapter createjpavendoradapter() {     openjpavendoradapter jpavendoradapter = new openjpavendoradapter();     jpavendoradapter.setshowsql(true);     return jpavendoradapter; }  public platformtransactionmanager transactionmanager(@qualifier("entitymanagerfactory")entitymanagerfactory entitymanagerfactory){     jtatransactionmanager transactionmanager = new jtatransactionmanager();     return transactionmanager; } 

}

persistence.xml

<persistence-unit name="sample" transaction-type="jta" >     <description>generated-persistence-unit</description>     <provider>org.apache.openjpa.persistence.persistenceproviderimpl</provider>     <class> ... </class>  </persistence-unit> 

i have configured wildfly server 10. both xa-datasources point different databases. however, when application boots , execute query fetches data datasource passed builder twice. seems have wrong slice configuration. not sure whats problem in case.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -