MyBatis Guice - ExecutorType REUSE not recognized

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

MyBatis Guice - ExecutorType REUSE not recognized

xeredi
Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("mybatis.environment.id", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

Poitras Christian
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<mailto:[hidden email]>> on behalf of xeredi <[hidden email]<mailto:[hidden email]>>
Répondre à : "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<mailto:[hidden email]>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("mybatis.environment.id", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<mailto:[hidden email]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

xeredi
Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email] escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>> on behalf of xeredi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xeredi@...>>
Répondre à : "<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">mybatis.environment.id", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1L2VpkffBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

Poitras Christian
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <[hidden email]<mailto:[hidden email]>> on behalf of xeredi <[hidden email]<mailto:[hidden email]>>
Répondre à : "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <[hidden email]<mailto:[hidden email]>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("mybatis.environment.id<http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<mailto:[hidden email]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

xeredi
Hi, this is the class where i'm configuring the mybatis module. The class annotated with Transactional is "ParametroServiceImpl", the interface is "ParametroService", and the line where I bind it is "bind(ParametroService.class).to(ParametroServiceImpl.class);". Is OK or did I something wrong? Thank you very much for your help.

public final class ArgoGuiceModule extends MyBatisModule {

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "portico");
properties.setProperty("JDBC.password", "portico");
properties.setProperty("JDBC.autoCommit", "false");

bindDataSourceProviderType(BoneCPProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);
environmentId("local");

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
// configuration.setLogImpl(NoLoggingImpl.class);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

Names.bindProperties(binder(), properties);

addSimpleAliases("xeredi.argo.model.comun.vo");
addSimpleAliases("xeredi.argo.model.estadistica.vo");
addSimpleAliases("xeredi.argo.model.facturacion.vo");
addSimpleAliases("xeredi.argo.model.item.vo");
addSimpleAliases("xeredi.argo.model.maestro.vo");
addSimpleAliases("xeredi.argo.model.metamodelo.vo");
addSimpleAliases("xeredi.argo.model.seguridad.vo");
addSimpleAliases("xeredi.argo.model.servicio.vo");

addMapperClasses("xeredi.argo.model.comun.dao");
addMapperClasses("xeredi.argo.model.estadistica.dao");
addMapperClasses("xeredi.argo.model.facturacion.dao");
addMapperClasses("xeredi.argo.model.maestro.dao");
addMapperClasses("xeredi.argo.model.maestro.dao.embdeportivas");
addMapperClasses("xeredi.argo.model.metamodelo.dao");
addMapperClasses("xeredi.argo.model.seguridad.dao");
addMapperClasses("xeredi.argo.model.servicio.dao");

// setEnvironmentId("local");
// setClassPathResource("mybatis-config.xml");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
bind(ConfigurationService.class).to(ConfigurationServiceImpl.class);
bind(ConfigurationProxyService.class).to(ConfigurationProxyServiceImpl.class);
bind(I18nService.class).to(I18nServiceImpl.class);
bind(PuertoService.class).to(PuertoServiceImpl.class);
bind(SuperpuertoService.class).to(SuperpuertoServiceImpl.class);
bind(CodigoReferenciaService.class).to(CodigoReferenciaServiceImpl.class);
bind(TipoDatoService.class).to(TipoDatoServiceImpl.class);
bind(TramiteService.class).to(TramiteServiceImpl.class);
bind(TramiteProxyService.class).to(TramiteProxyServiceImpl.class);
bind(TramiteTipoDatoService.class).to(TramiteTipoDatoServiceImpl.class);
bind(ModuloService.class).to(ModuloServiceImpl.class);
bind(EntidadService.class).to(EntidadServiceImpl.class);
bind(EntidadEntidadService.class).to(EntidadEntidadServiceImpl.class);
bind(EntidadGrupoDatoService.class).to(EntidadGrupoDatoServiceImpl.class);
bind(EntidadTipoDatoService.class).to(EntidadTipoDatoServiceImpl.class);
bind(TipoEstadisticaService.class).to(TipoEstadisticaServiceImpl.class);
bind(TipoParametroService.class).to(TipoParametroServiceImpl.class);
bind(TipoServicioService.class).to(TipoServicioServiceImpl.class);
bind(AccionBaseService.class).to(AccionBaseServiceImpl.class);
bind(AccionEntidadService.class).to(AccionEntidadServiceImpl.class);
bind(AccionEntidadBaseService.class).to(AccionEntidadBaseServiceImpl.class);
bind(AccionEspecialService.class).to(AccionEspecialServiceImpl.class);
bind(CampoAgregacionService.class).to(CampoAgregacionServiceImpl.class);
bind(UsuarioService.class).to(UsuarioServiceImpl.class);
bind(UsuarioPermisoService.class).to(UsuarioPermisoServiceImpl.class);
bind(GrupoService.class).to(GrupoServiceImpl.class);
bind(ParametroService.class).to(ParametroServiceImpl.class);
bind(SubparametroService.class).to(SubparametroServiceImpl.class);
bind(AmarreDeportivoService.class).to(AmarreDeportivoServiceImpl.class);
bind(AspectoService.class).to(AspectoServiceImpl.class);
bind(AspectoCargoService.class).to(AspectoCargoServiceImpl.class);
bind(CargoService.class).to(CargoServiceImpl.class);
bind(ReglaService.class).to(ReglaServiceImpl.class);
bind(ReglaIncompatibleService.class).to(ReglaIncompatibleServiceImpl.class);
bind(PeriodoProcesoService.class).to(PeriodoProcesoServiceImpl.class);
bind(CuadroMesService.class).to(CuadroMesServiceImpl.class);
bind(EstadisticaService.class).to(EstadisticaServiceImpl.class);
}

}




El viernes, 6 de enero de 2017, 16:12:02 (UTC+1), [hidden email] escribió:
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>> on behalf of xeredi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xeredi@...>>
Répondre à : "<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">mybatis.environment.id<<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sxP0tgUJBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

Poitras Christian
Hi,

Your configuration seems ok to me.


What is the result of your output this line?
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());

If the result is true, then the configuration is probably ok, but the transaction is failing to roll back properly. This could be due to auto commit flag in the connection. You can test this using this line.
System.out.println(“connection autocommit: " + manager.getConnection().getAutoCommit());

Christian

De : <[hidden email]<mailto:[hidden email]>> on behalf of xeredi <[hidden email]<mailto:[hidden email]>>
Répondre à : "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date : Friday, January 6, 2017 at 11:19 AM
À : mybatis-user <[hidden email]<mailto:[hidden email]>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, this is the class where i'm configuring the mybatis module. The class annotated with Transactional is "ParametroServiceImpl", the interface is "ParametroService", and the line where I bind it is "bind(ParametroService.class).to(ParametroServiceImpl.class);". Is OK or did I something wrong? Thank you very much for your help.

public final class ArgoGuiceModule extends MyBatisModule {

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "portico");
properties.setProperty("JDBC.password", "portico");
properties.setProperty("JDBC.autoCommit", "false");

bindDataSourceProviderType(BoneCPProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);
environmentId("local");

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
// configuration.setLogImpl(NoLoggingImpl.class);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

Names.bindProperties(binder(), properties);

addSimpleAliases("xeredi.argo.model.comun.vo");
addSimpleAliases("xeredi.argo.model.estadistica.vo");
addSimpleAliases("xeredi.argo.model.facturacion.vo");
addSimpleAliases("xeredi.argo.model.item.vo");
addSimpleAliases("xeredi.argo.model.maestro.vo");
addSimpleAliases("xeredi.argo.model.metamodelo.vo");
addSimpleAliases("xeredi.argo.model.seguridad.vo");
addSimpleAliases("xeredi.argo.model.servicio.vo");

addMapperClasses("xeredi.argo.model.comun.dao");
addMapperClasses("xeredi.argo.model.estadistica.dao");
addMapperClasses("xeredi.argo.model.facturacion.dao");
addMapperClasses("xeredi.argo.model.maestro.dao");
addMapperClasses("xeredi.argo.model.maestro.dao.embdeportivas");
addMapperClasses("xeredi.argo.model.metamodelo.dao");
addMapperClasses("xeredi.argo.model.seguridad.dao");
addMapperClasses("xeredi.argo.model.servicio.dao");

// setEnvironmentId("local");
// setClassPathResource("mybatis-config.xml");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
bind(ConfigurationService.class).to(ConfigurationServiceImpl.class);
bind(ConfigurationProxyService.class).to(ConfigurationProxyServiceImpl.class);
bind(I18nService.class).to(I18nServiceImpl.class);
bind(PuertoService.class).to(PuertoServiceImpl.class);
bind(SuperpuertoService.class).to(SuperpuertoServiceImpl.class);
bind(CodigoReferenciaService.class).to(CodigoReferenciaServiceImpl.class);
bind(TipoDatoService.class).to(TipoDatoServiceImpl.class);
bind(TramiteService.class).to(TramiteServiceImpl.class);
bind(TramiteProxyService.class).to(TramiteProxyServiceImpl.class);
bind(TramiteTipoDatoService.class).to(TramiteTipoDatoServiceImpl.class);
bind(ModuloService.class).to(ModuloServiceImpl.class);
bind(EntidadService.class).to(EntidadServiceImpl.class);
bind(EntidadEntidadService.class).to(EntidadEntidadServiceImpl.class);
bind(EntidadGrupoDatoService.class).to(EntidadGrupoDatoServiceImpl.class);
bind(EntidadTipoDatoService.class).to(EntidadTipoDatoServiceImpl.class);
bind(TipoEstadisticaService.class).to(TipoEstadisticaServiceImpl.class);
bind(TipoParametroService.class).to(TipoParametroServiceImpl.class);
bind(TipoServicioService.class).to(TipoServicioServiceImpl.class);
bind(AccionBaseService.class).to(AccionBaseServiceImpl.class);
bind(AccionEntidadService.class).to(AccionEntidadServiceImpl.class);
bind(AccionEntidadBaseService.class).to(AccionEntidadBaseServiceImpl.class);
bind(AccionEspecialService.class).to(AccionEspecialServiceImpl.class);
bind(CampoAgregacionService.class).to(CampoAgregacionServiceImpl.class);
bind(UsuarioService.class).to(UsuarioServiceImpl.class);
bind(UsuarioPermisoService.class).to(UsuarioPermisoServiceImpl.class);
bind(GrupoService.class).to(GrupoServiceImpl.class);
bind(ParametroService.class).to(ParametroServiceImpl.class);
bind(SubparametroService.class).to(SubparametroServiceImpl.class);
bind(AmarreDeportivoService.class).to(AmarreDeportivoServiceImpl.class);
bind(AspectoService.class).to(AspectoServiceImpl.class);
bind(AspectoCargoService.class).to(AspectoCargoServiceImpl.class);
bind(CargoService.class).to(CargoServiceImpl.class);
bind(ReglaService.class).to(ReglaServiceImpl.class);
bind(ReglaIncompatibleService.class).to(ReglaIncompatibleServiceImpl.class);
bind(PeriodoProcesoService.class).to(PeriodoProcesoServiceImpl.class);
bind(CuadroMesService.class).to(CuadroMesServiceImpl.class);
bind(EstadisticaService.class).to(EstadisticaServiceImpl.class);
}

}




El viernes, 6 de enero de 2017, 16:12:02 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("mybatis.environment.id<http://mybatis.environment.id><http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<mailto:[hidden email]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

xeredi
Hi:

manager.ManagedSessionStarted: false

And when I try To access the connection to see the autocommit, I got this exception:

org.apache.ibatis.session.SqlSessionException: Error:  Cannot get connection.  No managed session is started.
at org.apache.ibatis.session.SqlSessionManager.getConnection(SqlSessionManager.java:268)
at xeredi.argo.model.maestro.service.ParametroServiceImpl.update(ParametroServiceImpl.java:421)


El viernes, 6 de enero de 2017, 17:46:52 (UTC+1), [hidden email] escribió:
Hi,

Your configuration seems ok to me.


What is the result of your output this line?
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());

If the result is true, then the configuration is probably ok, but the transaction is failing to roll back properly. This could be due to auto commit flag in the connection. You can test this using this line.
System.out.println(“connection autocommit: " + manager.getConnection().getAutoCommit());

Christian

De : <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>> on behalf of xeredi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xeredi@...>>
Répondre à : "<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Date : Friday, January 6, 2017 at 11:19 AM
À : mybatis-user <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, this is the class where i'm configuring the mybatis module. The class annotated with Transactional is "ParametroServiceImpl", the interface is "ParametroService", and the line where I bind it is "bind(ParametroService.class).to(ParametroServiceImpl.class);". Is OK or did I something wrong? Thank you very much for your help.

public final class ArgoGuiceModule extends MyBatisModule {

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "portico");
properties.setProperty("JDBC.password", "portico");
properties.setProperty("JDBC.autoCommit", "false");

bindDataSourceProviderType(BoneCPProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);
environmentId("local");

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
// configuration.setLogImpl(NoLoggingImpl.class);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

Names.bindProperties(binder(), properties);

addSimpleAliases("xeredi.argo.model.comun.vo");
addSimpleAliases("xeredi.argo.model.estadistica.vo");
addSimpleAliases("xeredi.argo.model.facturacion.vo");
addSimpleAliases("xeredi.argo.model.item.vo");
addSimpleAliases("xeredi.argo.model.maestro.vo");
addSimpleAliases("xeredi.argo.model.metamodelo.vo");
addSimpleAliases("xeredi.argo.model.seguridad.vo");
addSimpleAliases("xeredi.argo.model.servicio.vo");

addMapperClasses("xeredi.argo.model.comun.dao");
addMapperClasses("xeredi.argo.model.estadistica.dao");
addMapperClasses("xeredi.argo.model.facturacion.dao");
addMapperClasses("xeredi.argo.model.maestro.dao");
addMapperClasses("xeredi.argo.model.maestro.dao.embdeportivas");
addMapperClasses("xeredi.argo.model.metamodelo.dao");
addMapperClasses("xeredi.argo.model.seguridad.dao");
addMapperClasses("xeredi.argo.model.servicio.dao");

// setEnvironmentId("local");
// setClassPathResource("mybatis-config.xml");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
bind(ConfigurationService.class).to(ConfigurationServiceImpl.class);
bind(ConfigurationProxyService.class).to(ConfigurationProxyServiceImpl.class);
bind(I18nService.class).to(I18nServiceImpl.class);
bind(PuertoService.class).to(PuertoServiceImpl.class);
bind(SuperpuertoService.class).to(SuperpuertoServiceImpl.class);
bind(CodigoReferenciaService.class).to(CodigoReferenciaServiceImpl.class);
bind(TipoDatoService.class).to(TipoDatoServiceImpl.class);
bind(TramiteService.class).to(TramiteServiceImpl.class);
bind(TramiteProxyService.class).to(TramiteProxyServiceImpl.class);
bind(TramiteTipoDatoService.class).to(TramiteTipoDatoServiceImpl.class);
bind(ModuloService.class).to(ModuloServiceImpl.class);
bind(EntidadService.class).to(EntidadServiceImpl.class);
bind(EntidadEntidadService.class).to(EntidadEntidadServiceImpl.class);
bind(EntidadGrupoDatoService.class).to(EntidadGrupoDatoServiceImpl.class);
bind(EntidadTipoDatoService.class).to(EntidadTipoDatoServiceImpl.class);
bind(TipoEstadisticaService.class).to(TipoEstadisticaServiceImpl.class);
bind(TipoParametroService.class).to(TipoParametroServiceImpl.class);
bind(TipoServicioService.class).to(TipoServicioServiceImpl.class);
bind(AccionBaseService.class).to(AccionBaseServiceImpl.class);
bind(AccionEntidadService.class).to(AccionEntidadServiceImpl.class);
bind(AccionEntidadBaseService.class).to(AccionEntidadBaseServiceImpl.class);
bind(AccionEspecialService.class).to(AccionEspecialServiceImpl.class);
bind(CampoAgregacionService.class).to(CampoAgregacionServiceImpl.class);
bind(UsuarioService.class).to(UsuarioServiceImpl.class);
bind(UsuarioPermisoService.class).to(UsuarioPermisoServiceImpl.class);
bind(GrupoService.class).to(GrupoServiceImpl.class);
bind(ParametroService.class).to(ParametroServiceImpl.class);
bind(SubparametroService.class).to(SubparametroServiceImpl.class);
bind(AmarreDeportivoService.class).to(AmarreDeportivoServiceImpl.class);
bind(AspectoService.class).to(AspectoServiceImpl.class);
bind(AspectoCargoService.class).to(AspectoCargoServiceImpl.class);
bind(CargoService.class).to(CargoServiceImpl.class);
bind(ReglaService.class).to(ReglaServiceImpl.class);
bind(ReglaIncompatibleService.class).to(ReglaIncompatibleServiceImpl.class);
bind(PeriodoProcesoService.class).to(PeriodoProcesoServiceImpl.class);
bind(CuadroMesService.class).to(CuadroMesServiceImpl.class);
bind(EstadisticaService.class).to(EstadisticaServiceImpl.class);
}

}




El viernes, 6 de enero de 2017, 16:12:02 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">mybatis.environment.id<<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id><<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:><javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BoZfgzIOBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

Poitras Christian
Hi,

The second error is normal if the transaction was not started.
And I found your mistake.

Transactional methods and classes must not be final. Methods are overwritten by the @Transactional annotation. So a method marked as final will never be transactional.

Best regards,
Christian

De : <[hidden email]<mailto:[hidden email]>> on behalf of xeredi <[hidden email]<mailto:[hidden email]>>
Répondre à : "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date : Friday, January 6, 2017 at 12:02 PM
À : mybatis-user <[hidden email]<mailto:[hidden email]>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi:

manager.ManagedSessionStarted: false

And when I try To access the connection to see the autocommit, I got this exception:

org.apache.ibatis.session.SqlSessionException: Error:  Cannot get connection.  No managed session is started.
at org.apache.ibatis.session.SqlSessionManager.getConnection(SqlSessionManager.java:268)
at xeredi.argo.model.maestro.service.ParametroServiceImpl.update(ParametroServiceImpl.java:421)


El viernes, 6 de enero de 2017, 17:46:52 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

Your configuration seems ok to me.


What is the result of your output this line?
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());

If the result is true, then the configuration is probably ok, but the transaction is failing to roll back properly. This could be due to auto commit flag in the connection. You can test this using this line.
System.out.println(“connection autocommit: " + manager.getConnection().getAutoCommit());

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Friday, January 6, 2017 at 11:19 AM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, this is the class where i'm configuring the mybatis module. The class annotated with Transactional is "ParametroServiceImpl", the interface is "ParametroService", and the line where I bind it is "bind(ParametroService.class).to(ParametroServiceImpl.class);". Is OK or did I something wrong? Thank you very much for your help.

public final class ArgoGuiceModule extends MyBatisModule {

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "portico");
properties.setProperty("JDBC.password", "portico");
properties.setProperty("JDBC.autoCommit", "false");

bindDataSourceProviderType(BoneCPProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);
environmentId("local");

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
// configuration.setLogImpl(NoLoggingImpl.class);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

Names.bindProperties(binder(), properties);

addSimpleAliases("xeredi.argo.model.comun.vo");
addSimpleAliases("xeredi.argo.model.estadistica.vo");
addSimpleAliases("xeredi.argo.model.facturacion.vo");
addSimpleAliases("xeredi.argo.model.item.vo");
addSimpleAliases("xeredi.argo.model.maestro.vo");
addSimpleAliases("xeredi.argo.model.metamodelo.vo");
addSimpleAliases("xeredi.argo.model.seguridad.vo");
addSimpleAliases("xeredi.argo.model.servicio.vo");

addMapperClasses("xeredi.argo.model.comun.dao");
addMapperClasses("xeredi.argo.model.estadistica.dao");
addMapperClasses("xeredi.argo.model.facturacion.dao");
addMapperClasses("xeredi.argo.model.maestro.dao");
addMapperClasses("xeredi.argo.model.maestro.dao.embdeportivas");
addMapperClasses("xeredi.argo.model.metamodelo.dao");
addMapperClasses("xeredi.argo.model.seguridad.dao");
addMapperClasses("xeredi.argo.model.servicio.dao");

// setEnvironmentId("local");
// setClassPathResource("mybatis-config.xml");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
bind(ConfigurationService.class).to(ConfigurationServiceImpl.class);
bind(ConfigurationProxyService.class).to(ConfigurationProxyServiceImpl.class);
bind(I18nService.class).to(I18nServiceImpl.class);
bind(PuertoService.class).to(PuertoServiceImpl.class);
bind(SuperpuertoService.class).to(SuperpuertoServiceImpl.class);
bind(CodigoReferenciaService.class).to(CodigoReferenciaServiceImpl.class);
bind(TipoDatoService.class).to(TipoDatoServiceImpl.class);
bind(TramiteService.class).to(TramiteServiceImpl.class);
bind(TramiteProxyService.class).to(TramiteProxyServiceImpl.class);
bind(TramiteTipoDatoService.class).to(TramiteTipoDatoServiceImpl.class);
bind(ModuloService.class).to(ModuloServiceImpl.class);
bind(EntidadService.class).to(EntidadServiceImpl.class);
bind(EntidadEntidadService.class).to(EntidadEntidadServiceImpl.class);
bind(EntidadGrupoDatoService.class).to(EntidadGrupoDatoServiceImpl.class);
bind(EntidadTipoDatoService.class).to(EntidadTipoDatoServiceImpl.class);
bind(TipoEstadisticaService.class).to(TipoEstadisticaServiceImpl.class);
bind(TipoParametroService.class).to(TipoParametroServiceImpl.class);
bind(TipoServicioService.class).to(TipoServicioServiceImpl.class);
bind(AccionBaseService.class).to(AccionBaseServiceImpl.class);
bind(AccionEntidadService.class).to(AccionEntidadServiceImpl.class);
bind(AccionEntidadBaseService.class).to(AccionEntidadBaseServiceImpl.class);
bind(AccionEspecialService.class).to(AccionEspecialServiceImpl.class);
bind(CampoAgregacionService.class).to(CampoAgregacionServiceImpl.class);
bind(UsuarioService.class).to(UsuarioServiceImpl.class);
bind(UsuarioPermisoService.class).to(UsuarioPermisoServiceImpl.class);
bind(GrupoService.class).to(GrupoServiceImpl.class);
bind(ParametroService.class).to(ParametroServiceImpl.class);
bind(SubparametroService.class).to(SubparametroServiceImpl.class);
bind(AmarreDeportivoService.class).to(AmarreDeportivoServiceImpl.class);
bind(AspectoService.class).to(AspectoServiceImpl.class);
bind(AspectoCargoService.class).to(AspectoCargoServiceImpl.class);
bind(CargoService.class).to(CargoServiceImpl.class);
bind(ReglaService.class).to(ReglaServiceImpl.class);
bind(ReglaIncompatibleService.class).to(ReglaIncompatibleServiceImpl.class);
bind(PeriodoProcesoService.class).to(PeriodoProcesoServiceImpl.class);
bind(CuadroMesService.class).to(CuadroMesServiceImpl.class);
bind(EstadisticaService.class).to(EstadisticaServiceImpl.class);
}

}




El viernes, 6 de enero de 2017, 16:12:02 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("mybatis.environment.id<http://mybatis.environment.id><http://mybatis.environment.id><http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:><javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<mailto:[hidden email]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

xeredi
Oh... you were right. Thanks!! You're Mybatis's Michael Jordan!

Now transactions run right, but I found another problem.

executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
});

These parameters are not working, it only works if I use:

@Transactional(executorType = ExecutorType.BATCH)

At class level or method level. Should I open a ticket? Thank you very much for your time.

El viernes, 6 de enero de 2017, 18:08:26 (UTC+1), [hidden email] escribió:
Hi,

The second error is normal if the transaction was not started.
And I found your mistake.

Transactional methods and classes must not be final. Methods are overwritten by the @Transactional annotation. So a method marked as final will never be transactional.

Best regards,
Christian

De : <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>> on behalf of xeredi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xeredi@...>>
Répondre à : "<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Date : Friday, January 6, 2017 at 12:02 PM
À : mybatis-user <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi:

manager.ManagedSessionStarted: false

And when I try To access the connection to see the autocommit, I got this exception:

org.apache.ibatis.session.SqlSessionException: Error:  Cannot get connection.  No managed session is started.
at org.apache.ibatis.session.SqlSessionManager.getConnection(SqlSessionManager.java:268)
at xeredi.argo.model.maestro.service.ParametroServiceImpl.update(ParametroServiceImpl.java:421)


El viernes, 6 de enero de 2017, 17:46:52 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

Your configuration seems ok to me.


What is the result of your output this line?
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());

If the result is true, then the configuration is probably ok, but the transaction is failing to roll back properly. This could be due to auto commit flag in the connection. You can test this using this line.
System.out.println(“connection autocommit: " + manager.getConnection().getAutoCommit());

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Friday, January 6, 2017 at 11:19 AM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, this is the class where i'm configuring the mybatis module. The class annotated with Transactional is "ParametroServiceImpl", the interface is "ParametroService", and the line where I bind it is "bind(ParametroService.class).to(ParametroServiceImpl.class);". Is OK or did I something wrong? Thank you very much for your help.

public final class ArgoGuiceModule extends MyBatisModule {

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "portico");
properties.setProperty("JDBC.password", "portico");
properties.setProperty("JDBC.autoCommit", "false");

bindDataSourceProviderType(BoneCPProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);
environmentId("local");

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
// configuration.setLogImpl(NoLoggingImpl.class);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

Names.bindProperties(binder(), properties);

addSimpleAliases("xeredi.argo.model.comun.vo");
addSimpleAliases("xeredi.argo.model.estadistica.vo");
addSimpleAliases("xeredi.argo.model.facturacion.vo");
addSimpleAliases("xeredi.argo.model.item.vo");
addSimpleAliases("xeredi.argo.model.maestro.vo");
addSimpleAliases("xeredi.argo.model.metamodelo.vo");
addSimpleAliases("xeredi.argo.model.seguridad.vo");
addSimpleAliases("xeredi.argo.model.servicio.vo");

addMapperClasses("xeredi.argo.model.comun.dao");
addMapperClasses("xeredi.argo.model.estadistica.dao");
addMapperClasses("xeredi.argo.model.facturacion.dao");
addMapperClasses("xeredi.argo.model.maestro.dao");
addMapperClasses("xeredi.argo.model.maestro.dao.embdeportivas");
addMapperClasses("xeredi.argo.model.metamodelo.dao");
addMapperClasses("xeredi.argo.model.seguridad.dao");
addMapperClasses("xeredi.argo.model.servicio.dao");

// setEnvironmentId("local");
// setClassPathResource("mybatis-config.xml");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
bind(ConfigurationService.class).to(ConfigurationServiceImpl.class);
bind(ConfigurationProxyService.class).to(ConfigurationProxyServiceImpl.class);
bind(I18nService.class).to(I18nServiceImpl.class);
bind(PuertoService.class).to(PuertoServiceImpl.class);
bind(SuperpuertoService.class).to(SuperpuertoServiceImpl.class);
bind(CodigoReferenciaService.class).to(CodigoReferenciaServiceImpl.class);
bind(TipoDatoService.class).to(TipoDatoServiceImpl.class);
bind(TramiteService.class).to(TramiteServiceImpl.class);
bind(TramiteProxyService.class).to(TramiteProxyServiceImpl.class);
bind(TramiteTipoDatoService.class).to(TramiteTipoDatoServiceImpl.class);
bind(ModuloService.class).to(ModuloServiceImpl.class);
bind(EntidadService.class).to(EntidadServiceImpl.class);
bind(EntidadEntidadService.class).to(EntidadEntidadServiceImpl.class);
bind(EntidadGrupoDatoService.class).to(EntidadGrupoDatoServiceImpl.class);
bind(EntidadTipoDatoService.class).to(EntidadTipoDatoServiceImpl.class);
bind(TipoEstadisticaService.class).to(TipoEstadisticaServiceImpl.class);
bind(TipoParametroService.class).to(TipoParametroServiceImpl.class);
bind(TipoServicioService.class).to(TipoServicioServiceImpl.class);
bind(AccionBaseService.class).to(AccionBaseServiceImpl.class);
bind(AccionEntidadService.class).to(AccionEntidadServiceImpl.class);
bind(AccionEntidadBaseService.class).to(AccionEntidadBaseServiceImpl.class);
bind(AccionEspecialService.class).to(AccionEspecialServiceImpl.class);
bind(CampoAgregacionService.class).to(CampoAgregacionServiceImpl.class);
bind(UsuarioService.class).to(UsuarioServiceImpl.class);
bind(UsuarioPermisoService.class).to(UsuarioPermisoServiceImpl.class);
bind(GrupoService.class).to(GrupoServiceImpl.class);
bind(ParametroService.class).to(ParametroServiceImpl.class);
bind(SubparametroService.class).to(SubparametroServiceImpl.class);
bind(AmarreDeportivoService.class).to(AmarreDeportivoServiceImpl.class);
bind(AspectoService.class).to(AspectoServiceImpl.class);
bind(AspectoCargoService.class).to(AspectoCargoServiceImpl.class);
bind(CargoService.class).to(CargoServiceImpl.class);
bind(ReglaService.class).to(ReglaServiceImpl.class);
bind(ReglaIncompatibleService.class).to(ReglaIncompatibleServiceImpl.class);
bind(PeriodoProcesoService.class).to(PeriodoProcesoServiceImpl.class);
bind(CuadroMesService.class).to(CuadroMesServiceImpl.class);
bind(EstadisticaService.class).to(EstadisticaServiceImpl.class);
}

}




El viernes, 6 de enero de 2017, 16:12:02 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">mybatis.environment.id<<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id><<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id><<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:><javascript:><javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:><javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RucBsV8PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

Poitras Christian
Hi,

You found the reason why SIMPLE is almost always used in my code. I forgot that @Transactional contains a executorType property that is SIMPLE by default.

Fixing this is difficult since it would change the behaviour for users that don’t read the changes when upgrading.

Best regards,
Christian

De : <[hidden email]<mailto:[hidden email]>> on behalf of xeredi <[hidden email]<mailto:[hidden email]>>
Répondre à : "[hidden email]<mailto:[hidden email]>" <[hidden email]<mailto:[hidden email]>>
Date : Friday, January 6, 2017 at 1:40 PM
À : mybatis-user <[hidden email]<mailto:[hidden email]>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Oh... you were right. Thanks!! You're Mybatis's Michael Jordan!

Now transactions run right, but I found another problem.

executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
});

These parameters are not working, it only works if I use:

@Transactional(executorType = ExecutorType.BATCH)

At class level or method level. Should I open a ticket? Thank you very much for your time.

El viernes, 6 de enero de 2017, 18:08:26 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

The second error is normal if the transaction was not started.
And I found your mistake.

Transactional methods and classes must not be final. Methods are overwritten by the @Transactional annotation. So a method marked as final will never be transactional.

Best regards,
Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Friday, January 6, 2017 at 12:02 PM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi:

manager.ManagedSessionStarted: false

And when I try To access the connection to see the autocommit, I got this exception:

org.apache.ibatis.session.SqlSessionException: Error:  Cannot get connection.  No managed session is started.
at org.apache.ibatis.session.SqlSessionManager.getConnection(SqlSessionManager.java:268)
at xeredi.argo.model.maestro.service.ParametroServiceImpl.update(ParametroServiceImpl.java:421)


El viernes, 6 de enero de 2017, 17:46:52 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

Your configuration seems ok to me.


What is the result of your output this line?
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());

If the result is true, then the configuration is probably ok, but the transaction is failing to roll back properly. This could be due to auto commit flag in the connection. You can test this using this line.
System.out.println(“connection autocommit: " + manager.getConnection().getAutoCommit());

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Friday, January 6, 2017 at 11:19 AM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, this is the class where i'm configuring the mybatis module. The class annotated with Transactional is "ParametroServiceImpl", the interface is "ParametroService", and the line where I bind it is "bind(ParametroService.class).to(ParametroServiceImpl.class);". Is OK or did I something wrong? Thank you very much for your help.

public final class ArgoGuiceModule extends MyBatisModule {

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "portico");
properties.setProperty("JDBC.password", "portico");
properties.setProperty("JDBC.autoCommit", "false");

bindDataSourceProviderType(BoneCPProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);
environmentId("local");

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
// configuration.setLogImpl(NoLoggingImpl.class);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

Names.bindProperties(binder(), properties);

addSimpleAliases("xeredi.argo.model.comun.vo");
addSimpleAliases("xeredi.argo.model.estadistica.vo");
addSimpleAliases("xeredi.argo.model.facturacion.vo");
addSimpleAliases("xeredi.argo.model.item.vo");
addSimpleAliases("xeredi.argo.model.maestro.vo");
addSimpleAliases("xeredi.argo.model.metamodelo.vo");
addSimpleAliases("xeredi.argo.model.seguridad.vo");
addSimpleAliases("xeredi.argo.model.servicio.vo");

addMapperClasses("xeredi.argo.model.comun.dao");
addMapperClasses("xeredi.argo.model.estadistica.dao");
addMapperClasses("xeredi.argo.model.facturacion.dao");
addMapperClasses("xeredi.argo.model.maestro.dao");
addMapperClasses("xeredi.argo.model.maestro.dao.embdeportivas");
addMapperClasses("xeredi.argo.model.metamodelo.dao");
addMapperClasses("xeredi.argo.model.seguridad.dao");
addMapperClasses("xeredi.argo.model.servicio.dao");

// setEnvironmentId("local");
// setClassPathResource("mybatis-config.xml");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
bind(ConfigurationService.class).to(ConfigurationServiceImpl.class);
bind(ConfigurationProxyService.class).to(ConfigurationProxyServiceImpl.class);
bind(I18nService.class).to(I18nServiceImpl.class);
bind(PuertoService.class).to(PuertoServiceImpl.class);
bind(SuperpuertoService.class).to(SuperpuertoServiceImpl.class);
bind(CodigoReferenciaService.class).to(CodigoReferenciaServiceImpl.class);
bind(TipoDatoService.class).to(TipoDatoServiceImpl.class);
bind(TramiteService.class).to(TramiteServiceImpl.class);
bind(TramiteProxyService.class).to(TramiteProxyServiceImpl.class);
bind(TramiteTipoDatoService.class).to(TramiteTipoDatoServiceImpl.class);
bind(ModuloService.class).to(ModuloServiceImpl.class);
bind(EntidadService.class).to(EntidadServiceImpl.class);
bind(EntidadEntidadService.class).to(EntidadEntidadServiceImpl.class);
bind(EntidadGrupoDatoService.class).to(EntidadGrupoDatoServiceImpl.class);
bind(EntidadTipoDatoService.class).to(EntidadTipoDatoServiceImpl.class);
bind(TipoEstadisticaService.class).to(TipoEstadisticaServiceImpl.class);
bind(TipoParametroService.class).to(TipoParametroServiceImpl.class);
bind(TipoServicioService.class).to(TipoServicioServiceImpl.class);
bind(AccionBaseService.class).to(AccionBaseServiceImpl.class);
bind(AccionEntidadService.class).to(AccionEntidadServiceImpl.class);
bind(AccionEntidadBaseService.class).to(AccionEntidadBaseServiceImpl.class);
bind(AccionEspecialService.class).to(AccionEspecialServiceImpl.class);
bind(CampoAgregacionService.class).to(CampoAgregacionServiceImpl.class);
bind(UsuarioService.class).to(UsuarioServiceImpl.class);
bind(UsuarioPermisoService.class).to(UsuarioPermisoServiceImpl.class);
bind(GrupoService.class).to(GrupoServiceImpl.class);
bind(ParametroService.class).to(ParametroServiceImpl.class);
bind(SubparametroService.class).to(SubparametroServiceImpl.class);
bind(AmarreDeportivoService.class).to(AmarreDeportivoServiceImpl.class);
bind(AspectoService.class).to(AspectoServiceImpl.class);
bind(AspectoCargoService.class).to(AspectoCargoServiceImpl.class);
bind(CargoService.class).to(CargoServiceImpl.class);
bind(ReglaService.class).to(ReglaServiceImpl.class);
bind(ReglaIncompatibleService.class).to(ReglaIncompatibleServiceImpl.class);
bind(PeriodoProcesoService.class).to(PeriodoProcesoServiceImpl.class);
bind(CuadroMesService.class).to(CuadroMesServiceImpl.class);
bind(EstadisticaService.class).to(EstadisticaServiceImpl.class);
}

}




El viernes, 6 de enero de 2017, 16:12:02 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:[hidden email]<javascript:>>" <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:[hidden email]<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("mybatis.environment.id<http://mybatis.environment.id><http://mybatis.environment.id><http://mybatis.environment.id><http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:><javascript:><javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:><javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<javascript:><mailto:[hidden email]<javascript:>>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]<mailto:[hidden email]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis Guice - ExecutorType REUSE not recognized

xeredi
Hi.

You're right, but I think with this change the code will run correctly.

- People who is not using the default executor will not be affected.
- People who is using the default executor will probably improve his app performance.

Thank you.


El viernes, 6 de enero de 2017, 20:08:02 (UTC+1), [hidden email] escribió:
Hi,

You found the reason why SIMPLE is almost always used in my code. I forgot that @Transactional contains a executorType property that is SIMPLE by default.

Fixing this is difficult since it would change the behaviour for users that don’t read the changes when upgrading.

Best regards,
Christian

De : <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>> on behalf of xeredi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xeredi@...>>
Répondre à : "<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Date : Friday, January 6, 2017 at 1:40 PM
À : mybatis-user <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Oh... you were right. Thanks!! You're Mybatis's Michael Jordan!

Now transactions run right, but I found another problem.

executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
});

These parameters are not working, it only works if I use:

@Transactional(executorType = ExecutorType.BATCH)

At class level or method level. Should I open a ticket? Thank you very much for your time.

El viernes, 6 de enero de 2017, 18:08:26 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

The second error is normal if the transaction was not started.
And I found your mistake.

Transactional methods and classes must not be final. Methods are overwritten by the @Transactional annotation. So a method marked as final will never be transactional.

Best regards,
Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">xer...@...<javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Friday, January 6, 2017 at 12:02 PM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi:

manager.ManagedSessionStarted: false

And when I try To access the connection to see the autocommit, I got this exception:

org.apache.ibatis.session.SqlSessionException: Error:  Cannot get connection.  No managed session is started.
at org.apache.ibatis.session.SqlSessionManager.getConnection(SqlSessionManager.java:268)
at xeredi.argo.model.maestro.service.ParametroServiceImpl.update(ParametroServiceImpl.java:421)


El viernes, 6 de enero de 2017, 17:46:52 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

Your configuration seems ok to me.


What is the result of your output this line?
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());

If the result is true, then the configuration is probably ok, but the transaction is failing to roll back properly. This could be due to auto commit flag in the connection. You can test this using this line.
System.out.println(“connection autocommit: " + manager.getConnection().getAutoCommit());

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Friday, January 6, 2017 at 11:19 AM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, this is the class where i'm configuring the mybatis module. The class annotated with Transactional is "ParametroServiceImpl", the interface is "ParametroService", and the line where I bind it is "bind(ParametroService.class).to(ParametroServiceImpl.class);". Is OK or did I something wrong? Thank you very much for your help.

public final class ArgoGuiceModule extends MyBatisModule {

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "portico");
properties.setProperty("JDBC.password", "portico");
properties.setProperty("JDBC.autoCommit", "false");

bindDataSourceProviderType(BoneCPProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);
environmentId("local");

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
// configuration.setLogImpl(NoLoggingImpl.class);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

Names.bindProperties(binder(), properties);

addSimpleAliases("xeredi.argo.model.comun.vo");
addSimpleAliases("xeredi.argo.model.estadistica.vo");
addSimpleAliases("xeredi.argo.model.facturacion.vo");
addSimpleAliases("xeredi.argo.model.item.vo");
addSimpleAliases("xeredi.argo.model.maestro.vo");
addSimpleAliases("xeredi.argo.model.metamodelo.vo");
addSimpleAliases("xeredi.argo.model.seguridad.vo");
addSimpleAliases("xeredi.argo.model.servicio.vo");

addMapperClasses("xeredi.argo.model.comun.dao");
addMapperClasses("xeredi.argo.model.estadistica.dao");
addMapperClasses("xeredi.argo.model.facturacion.dao");
addMapperClasses("xeredi.argo.model.maestro.dao");
addMapperClasses("xeredi.argo.model.maestro.dao.embdeportivas");
addMapperClasses("xeredi.argo.model.metamodelo.dao");
addMapperClasses("xeredi.argo.model.seguridad.dao");
addMapperClasses("xeredi.argo.model.servicio.dao");

// setEnvironmentId("local");
// setClassPathResource("mybatis-config.xml");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
bind(ConfigurationService.class).to(ConfigurationServiceImpl.class);
bind(ConfigurationProxyService.class).to(ConfigurationProxyServiceImpl.class);
bind(I18nService.class).to(I18nServiceImpl.class);
bind(PuertoService.class).to(PuertoServiceImpl.class);
bind(SuperpuertoService.class).to(SuperpuertoServiceImpl.class);
bind(CodigoReferenciaService.class).to(CodigoReferenciaServiceImpl.class);
bind(TipoDatoService.class).to(TipoDatoServiceImpl.class);
bind(TramiteService.class).to(TramiteServiceImpl.class);
bind(TramiteProxyService.class).to(TramiteProxyServiceImpl.class);
bind(TramiteTipoDatoService.class).to(TramiteTipoDatoServiceImpl.class);
bind(ModuloService.class).to(ModuloServiceImpl.class);
bind(EntidadService.class).to(EntidadServiceImpl.class);
bind(EntidadEntidadService.class).to(EntidadEntidadServiceImpl.class);
bind(EntidadGrupoDatoService.class).to(EntidadGrupoDatoServiceImpl.class);
bind(EntidadTipoDatoService.class).to(EntidadTipoDatoServiceImpl.class);
bind(TipoEstadisticaService.class).to(TipoEstadisticaServiceImpl.class);
bind(TipoParametroService.class).to(TipoParametroServiceImpl.class);
bind(TipoServicioService.class).to(TipoServicioServiceImpl.class);
bind(AccionBaseService.class).to(AccionBaseServiceImpl.class);
bind(AccionEntidadService.class).to(AccionEntidadServiceImpl.class);
bind(AccionEntidadBaseService.class).to(AccionEntidadBaseServiceImpl.class);
bind(AccionEspecialService.class).to(AccionEspecialServiceImpl.class);
bind(CampoAgregacionService.class).to(CampoAgregacionServiceImpl.class);
bind(UsuarioService.class).to(UsuarioServiceImpl.class);
bind(UsuarioPermisoService.class).to(UsuarioPermisoServiceImpl.class);
bind(GrupoService.class).to(GrupoServiceImpl.class);
bind(ParametroService.class).to(ParametroServiceImpl.class);
bind(SubparametroService.class).to(SubparametroServiceImpl.class);
bind(AmarreDeportivoService.class).to(AmarreDeportivoServiceImpl.class);
bind(AspectoService.class).to(AspectoServiceImpl.class);
bind(AspectoCargoService.class).to(AspectoCargoServiceImpl.class);
bind(CargoService.class).to(CargoServiceImpl.class);
bind(ReglaService.class).to(ReglaServiceImpl.class);
bind(ReglaIncompatibleService.class).to(ReglaIncompatibleServiceImpl.class);
bind(PeriodoProcesoService.class).to(PeriodoProcesoServiceImpl.class);
bind(CuadroMesService.class).to(CuadroMesServiceImpl.class);
bind(EstadisticaService.class).to(EstadisticaServiceImpl.class);
}

}




El viernes, 6 de enero de 2017, 16:12:02 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

It is probably a configuration problem. Are you binding this class in the MyBatisModule? You need to bind all classes using @Transactional in the MyBatisModule, otherwise, transactions may not be started properly.

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Friday, January 6, 2017 at 9:47 AM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : Re: MyBatis Guice - ExecutorType REUSE not recognized

Hi, thank you for your quick response. I think the problem is in autoCommit. This is my update function code:


/**
* {@inheritDoc}
*/
@Override
@Transactional(executorType = ExecutorType.REUSE)
public final void update(@NonNull final ParametroVO prmt, @NonNull final TipoParametroDetailVO tpprDetail,
final Map<String, I18nVO> i18nMap) throws OverlapException, InstanceNotFoundException {
Preconditions.checkNotNull(prmt.getVersion());
Preconditions.checkNotNull(prmt.getVersion().getId());

System.out
.println("manager.DefaultExecutorType: " + manager.getConfiguration().getDefaultExecutorType().name());
System.out.println("manager.ManagedSessionStarted: " + manager.isManagedSessionStarted());
System.out
.println("factory.DefaultExecutorType: " + factory.getConfiguration().getDefaultExecutorType().name());

if (tpprDetail.getEnti().isI18n()) {
Preconditions.checkNotNull(i18nMap);
}

if (tpprDetail.getEnti().isTempExp()) {
Preconditions.checkNotNull(prmt.getVersion().getFini());
}

// Validar que los datos del parametro son correctos
if (tpprDetail.getEntdList() != null && !tpprDetail.getEntdList().isEmpty()) {
for (final Long tpdtId : tpprDetail.getEntdList()) {
final EntidadTipoDatoVO entd = tpprDetail.getEntdMap().get(tpdtId);

if (!prmt.getItdtMap().containsKey(entd.getTpdt().getId())) {
throw new Error("No se ha pasado informacion del dato " + entd.getTpdt().getNombre()
+ " del parametro: " + prmt);
}
}
}

if (prmtDAO.existsOverlap(prmt)) {
throw new OverlapException(MessageI18nKey.prmt, prmt);
}

if (prmtDAO.updateVersion(prmt) == 0) {
throw new InstanceNotFoundException(prmt.getEntiId(), prmt);
}

if (tpprDetail.getEnti().isI18n()) {
I18nUtil.updateMap(i18nDAO, prmt, i18nMap);
}

if (prmt.getItdtMap() != null) {
for (final ItemDatoVO itdtVO : prmt.getItdtMap().values()) {
itdtVO.setItemId(prmt.getVersion().getId());
prdtDAO.update(itdtVO);
}

throw new Error("Quit!!");
}

updatePostOperations(prmt, tpprDetail, i18nMap);
}

I bolded the line where I'm forcing an error. It's a transaction, so It should do everything or nothing (in this case, nothing). But when I checked the result, i saw the operation partially completed. So I think the transaction is running in autocommit mode (so no transaction). Am I right? It's a configuration problem? If I run this code with "Pure Mybatis" works correctly.

Thank you very much.


El viernes, 6 de enero de 2017, 3:27:06 (UTC+1), [hidden email]<mailto:[hidden email]> escribió:
Hi,

I am not convinced that you’re doing anything wrong. Try injecting the SqlSessionManager or SqlSessionFactory in one of your Services/Daos and check the value of configuration’s execution type after configuration is over.

I think MyBatis will force SIMPLE as the execution type in many circonstances. REUSE is useful only in limited cases, since it can only reuse a statement in a single transaction.

By the way, the 2 ways you set execution type will work. It’s a mater of choice.
But, the “mybatis.*” properties you set using java.util.Properties may not work. MyBatis-Guice version 3.9 will fix this.

Christian

De : <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>> on behalf of xeredi <[hidden email]<javascript:><mailto:[hidden email]<javascript:><javascript:>>>
Répondre à : "[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>" <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Date : Thursday, January 5, 2017 at 2:24 PM
À : mybatis-user <[hidden email]<javascript:><mailto:mybati...@googlegroups.com<javascript:>>>
Objet : MyBatis Guice - ExecutorType REUSE not recognized

Hi.

Using mybatis-guice 3.8, I have this module configuration:

protected void initialize() {
final Properties properties = new Properties();

properties.setProperty("<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">mybatis.environment.id<<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id><<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id><<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id><<a href="http://mybatis.environment.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.environment.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFDIongnkMPfHxA4RIfUQqmOiOo6g&#39;;return true;">http://mybatis.environment.id>", "local");
properties.setProperty("JDBC.driver", "oracle.jdbc.OracleDriver");
properties.setProperty("JDBC.url", "jdbc:oracle:thin:@127.0.0.1:1521:orcl");
properties.setProperty("JDBC.username", "xxxxxx");
properties.setProperty("JDBC.password", "xxxxxx");
properties.setProperty("JDBC.autoCommit", "false");
properties.setProperty("mybatis.pooled.maximumActiveConnections", "4");
properties.setProperty("mybatis.pooled.maximumIdleConnections", "4");

Names.bindProperties(binder(), properties);

bindDataSourceProviderType(PooledDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
useCacheEnabled(false);
executorType(ExecutorType.REUSE);

bindConfigurationSetting(configuration -> {
configuration.setDefaultExecutorType(ExecutorType.REUSE);
configuration.setLogImpl(Log4jImpl.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setProxyFactory(new JavassistProxyFactory());
});

addSimpleAliases("xeredi.argo.model.comun.vo");

addMapperClasses("xeredi.argo.model.comun.dao");

bind(ArchivoService.class).to(ArchivoServiceImpl.class);
      }

I found 2 methods for setting the executorType, and I used both, because I'm not sure wich is the right method.
But when I run the application, looking in the LOG, i see the code is using ExecutorType.SIMPLE (I execute the same preparedstatement several times, and the LOG prints the SQL query several times, instead of reusing it).
Have I made any mistake in my module configuration? Thanks in advance (and excuse my horrible english)

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:><javascript:><javascript:><javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:><javascript:><javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:><javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com<javascript:><mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com<javascript:>>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com<mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OJ8OYOYVBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user+unsubscribe@googlegroups.com>.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.