Prop Key Hibernate.id.new_generator_mappings False Prop

  1. Prop Key= Hibernate.id.new_generator_mappings False /prop
Prop key hibernate.id.new_generator_mappings false property tax
  • Dear Brett, i am facing one issue while using hikariCP for oracle DB connection. I am using atomikos for transaction management. Problem if i am keeping autocommit as false transaction is not getti.
  • Nov 08, 2017  Dear Brett, i am facing one issue while using hikariCP for oracle DB connection. I am using atomikos for transaction management. Problem if i am keeping autocommit as false transaction is not getting committed although Jta is calling com.
  • Codesenior.COM is a web site which contains articles and codes related to Java, Android, PHP, C#/ASP.NET, C/C etc.
  1. @ContextHierarchy({
  2. @ContextConfiguration(value = 'file:src/main/webapp/WEB-INF/spring/applicationContext-db.xml'),
  3. @ContextConfiguration(value = 'file:src/main/webapp/WEB-INF/spring/applicationContext.xml')
  4. public class FileServiceImplTest {
  5. @Autowired
  6. public void testSaveFolder() {
  7. rootFolder.setName('ROOT');
  8. rootFolder.setIdPath('/');
  9. List<AbstractFileDTO> rootFiles = fileService.getRootFiles();
  10. assertEquals(1, rootFiles.size());
  11. AbstractFileDTO abstractFileDTO = rootFiles.get(0);
  12. assertEquals(rootFolder, abstractFileDTO);
  13. }
  14. }
  15. org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
  16. at org.springframework.orm.hibernate5.SpringSessionContext.currentSession(SpringSessionContext.java:132)
  17. at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:697)
  18. at org.sbezgin.p2016.db.dao.impl.FileDAOImpl.getSession(FileDAOImpl.java:69)
  19. at org.sbezgin.p2016.db.dao.impl.FileDAOImpl.saveOrUpdateFile(FileDAOImpl.java:33)
  20. at org.sbezgin.p2016.services.file.impl.FileServiceImpl.saveFile(FileServiceImpl.java:41)
  21. at org.sbezgin.p2016.services.file.impl.FileServiceImplTest.testSaveFolder(FileServiceImplTest.java:35)
  22. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  23. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  24. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  25. at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  26. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  27. at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  28. at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  29. at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
  30. at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
  31. at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
  32. at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  33. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254)
  34. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
  35. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  36. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  37. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  38. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  39. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  40. at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  41. at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  42. at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  43. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
  44. at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
  45. at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
  46. @Transactional
  47. public class FileServiceImpl implements FileService {
  48. private BeanTransformer beanTransformer;
  49. @Override
  50. public AbstractFileDTO getFileByID(long fileID) {
  51. }
  52. @Override
  53. return null;
  54. @Transactional(propagation = Propagation.REQUIRED)
  55. public void saveFile(AbstractFileDTO file) {
  56. if (id null) {
  57. AbstractFile fileEntity = (AbstractFile) beanTransformer.transformDTOToEntity(file);
  58. user.setId(1);
  59. }
  60. public void setPermission(long fileD, PermissionDTO perm) {
  61. }
  62. @Override
  63. public void renameFile(long fileID, String newName) {
  64. }
  65. @Override
  66. public void deleteFile(long fileID, boolean recursively) {
  67. }
  68. @Override
  69. User user = new User();
  70. List<AbstractFile> rootFiles = fileDAO.getRootFiles(user);
  71. List<AbstractFileDTO> abstractFileDTOs = new ArrayList<>(rootFiles.size());
  72. rootFiles.stream().map(
  73. rootFile -> (AbstractFileDTO) beanTransformer.transformEntityToDTO(rootFile)
  74. );
  75. }
  76. @Override
  77. public List<AbstractFileDTO> getChildren(long folderID) {
  78. }
  79. @Override
  80. public List<AbstractFileDTO> getFilesByType(String javaType) {
  81. }
  82. return fileDAO;
  83. this.fileDAO = fileDAO;
  84. return beanTransformer;
  85. public void setBeanTransformer(BeanTransformer beanTransformer) {
  86. }
  87. public AbstractFile getFileByID(User user, long fileID) {
  88. }
  89. @Override
  90. public Folder getFolder(User user, long folderID) {
  91. }
  92. @Transactional(propagation = Propagation.REQUIRED)
  93. public void saveOrUpdateFile(User user, AbstractFile file) {
  94. file.setClassName(file.getClass().getCanonicalName());
  95. session.save(file);
  96. public void saveOrUpdateFiles(User user, List<AbstractFile> files) {
  97. }
  98. @Override
  99. public void deleteFile(User user, long fileID, boolean recursively) {
  100. }
  101. @Override
  102. public List<AbstractFile> getRootFiles(User user) {
  103. Query query = session.createQuery('from AbstractFile as file where file.ownerID = :ownerId and file.parentId is null ');
  104. List list = query.list();
  105. }
  106. @Override
  107. public List<AbstractFile> getChildren(User user, long folderID) {
  108. }
  109. @Override
  110. public List<AbstractFile> getFilesByType(User user, String javaType) {
  111. }
  112. private Session getSession() {
  113. }
  114. public SessionFactory getSessionFactory() {
  115. }
  116. public void setSessionFactory(SessionFactory sessionFactory) {
  117. }
  118. <beans xmlns='http://www.springframework.org/schema/beans'
  119. xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  120. xmlns:context='http://www.springframework.org/schema/context'
  121. xmlns:tx='http://www.springframework.org/schema/tx'
  122. xmlns:aop='http://www.springframework.org/schema/aop'
  123. xsi:schemaLocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  124. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
  125. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
  126. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd'>
  127. <bean name='dozer' />
  128. <bean name='beanTransformer'>
  129. <property name='beanMap'>
  130. <entry key='org.sbezgin.p2016.db.dto.file.FolderDTO' value='org.sbezgin.p2016.db.entity.file.Folder'/>
  131. </property>
  132. <bean name='fileService'>
  133. <property name='beanTransformer' ref='beanTransformer'/>
  134. <bean name='fileDAO'>
  135. <property name='sessionFactory' ref='sessionFactory'/>
  136. </beans>
  137. <?xml version='1.0' encoding='UTF-8'?>
  138. <beans xmlns='http://www.springframework.org/schema/beans'
  139. xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  140. xmlns:context='http://www.springframework.org/schema/context'
  141. xmlns:tx='http://www.springframework.org/schema/tx'
  142. xmlns:aop='http://www.springframework.org/schema/aop'
  143. xsi:schemaLocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  144. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
  145. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
  146. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd'>
  147. <context:property-placeholder location='WEB-INF/hibernate.properties' ignore-unresolvable='false'/>
  148. <bean>
  149. <property name='driverClassName' value='${jdbc.driverClassName}'/>
  150. <property name='username' value='${jdbc.username}'/>
  151. <property name='password' value='${jdbc.password}'/>
  152. <bean>
  153. <property name='packagesToScan'>
  154. <value>org.sbezgin.p2016.db.entity</value>
  155. </property>
  156. <props>
  157. <prop key='hibernate.dialect'>${hibernate.dialect}</prop>
  158. <prop key='hibernate.show_sql'>${hibernate.show_sql:false}</prop>
  159. <prop key='hibernate.format_sql'>${hibernate.format_sql:false}</prop>
  160. <prop key='hibernate.id.new_generator_mappings'>${hibernate.id.new_generator_mappings}</prop>
  161. <prop key='hibernate.hbm2ddl.auto'>${hibernate.hbm2ddl.auto}</prop>
  162. </property>
  163. <bean>
  164. <property name='sessionFactory' ref='sessionFactory'/>
  165. <tx:annotation-driven transaction-manager='transactionManager'/>
  166. </beans>
  167. jdbc.driverClassName = org.hsqldb.jdbcDriver
  168. jdbc.username = sa
  169. hibernate.dialect = org.hibernate.dialect.HSQLDialect
  170. hibernate.format_sql = true
  171. hibernate.hbm2ddl.auto = create-drop
  172. <dependencies>
  173. <groupId>org.hibernate</groupId>
  174. <version>5.0.7.Final</version>
  175. <dependency>
  176. <artifactId>spring-context</artifactId>
  177. </dependency>
  178. <groupId>org.springframework</groupId>
  179. <version>4.2.4.RELEASE</version>
  180. <dependency>
  181. <artifactId>spring-tx</artifactId>
  182. </dependency>
  183. <groupId>org.springframework</groupId>
  184. <version>4.2.4.RELEASE</version>
  185. <dependency>
  186. <artifactId>dozer</artifactId>
  187. </dependency>
  188. <groupId>mysql</groupId>
  189. <version>5.1.38</version>
  190. <groupId>javax.servlet</groupId>
  191. <version>3.0.1</version>
  192. </dependency>
  193. <dependency>
  194. <artifactId>mockito-all</artifactId>
  195. </dependency>
  196. <groupId>org.powermock</groupId>
  197. <version>1.5</version>
  198. </dependency>
  199. <groupId>org.powermock</groupId>
  200. <version>1.5</version>
  201. </dependency>
  202. <groupId>junit</groupId>
  203. <version>4.11</version>
  204. </dependency>
  205. <groupId>org.springframework</groupId>
  206. <version>4.2.4.RELEASE</version>
  207. </dependency>
  208. <groupId>org.hsqldb</groupId>
  209. <version>2.2.8</version>
  210. </dependency>
  211. <build>
  212. <plugins>
  213. <!-- current version -->
  214. <artifactId>hsqldb-maven-plugin</artifactId>
  215. default value for in memory jdbc:hsqldb:hsql://localhost/xdb
  216. -->
  217. <driver>org.hsqldb.jdbcDriver</driver>
  218. <port>9001</port>
  219. <username>sa</username>
  220. <validationQuery>SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS</validationQuery>
  221. <executions>
  222. <id>start-hsqldb</id>
  223. <goals>
  224. </goals>
  225. <execution>
  226. <phase>post-integration-test</phase>
  227. <goal>stop</goal>
  228. </execution>
  229. </plugin>
  230. <groupId>org.apache.maven.plugins</groupId>
  231. <version>3.3</version>
  232. <source>1.8</source>
  233. </configuration>
  234. </plugins>
  235. </project>

Prop Key= Hibernate.id.new_generator_mappings False /prop

When Hibernate applications are deployed on JBoss Enterprise Application Platform 6, the hibernate.id.newgeneratormappings property defaults to false. If there is not existing entities created in the database yet, consider changing hibernate.id.newgeneratormappings to true. Dec 27, 2018  Overview Suppose you have a Spring MVC application which has been running on Wildfly server. This application uses following features/configurations: It uses Spring annotations. It uses JPA and thus has entity manager configured in its XML configuration. I was getting the same error-“com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘mylocaldb.hibernatesequence’ doesn’t exist”. Using spring mvc 4.3.7 and hibernate version 5.2.9, application is made using spring java based configuration, now i have to add the “hibernate.id.newgeneratormappings” property mentioned.