Guest User

Untitled

a guest
Jun 25th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.94 KB | None | 0 0
  1. ├── pom.xml
  2. └── src
  3. ├── main
  4. │   ├── java
  5. │   │   └── com
  6. │   │   └── thalasoft
  7. │   │   └── userdata
  8. │   │   ├── config
  9. │   │   │   ├── DatabaseConfiguration.java
  10. │   │   │   ├── JpaService.java
  11. │   │   │   └── properties
  12. │   │   │   ├── AbstractDatabaseProperties.java
  13. │   │   │   ├── DatabaseH2TestProperties.java
  14. │   │   │   ├── DatabaseMySQLAcceptanceProperties.java
  15. │   │   │   ├── DatabaseMySQLPreProdProperties.java
  16. │   │   │   ├── DatabaseMySQLProdProperties.java
  17. │   │   │   ├── DatabaseMySQLTestProperties.java
  18. │   │   │   ├── DatabaseOraclePreProdProperties.java
  19. │   │   │   ├── DatabaseOracleProdProperties.java
  20. │   │   │   ├── DatabaseOracleTestProperties.java
  21. │   │   │   ├── DatabaseProperties.java
  22. │   │   │   └── PropertyNames.java
  23. │   │   ├── dialect
  24. │   │   │   ├── CustomMySQL5InnoDBDialect.java
  25. │   │   │   └── CustomOracle10gDialect.java
  26. │   │   ├── exception
  27. │   │   │   ├── CannotDeleteEntityException.java
  28. │   │   │   ├── EnrichableException.java
  29. │   │   │   ├── EntityAlreadyExistsException.java
  30. │   │   │   ├── EntityNotFoundException.java
  31. │   │   │   └── NoEntitiesFoundException.java
  32. │   │   ├── jpa
  33. │   │   │   ├── domain
  34. │   │   │   │   ├── AbstractEntity.java
  35. │   │   │   │   ├── EmailAddress.java
  36. │   │   │   │   ├── User.java
  37. │   │   │   │   └── UserRole.java
  38. │   │   │   └── repository
  39. │   │   │   ├── GenericRepositoryImpl.java
  40. │   │   │   ├── GenericRepository.java
  41. │   │   │   ├── UserRepositoryCustom.java
  42. │   │   │   ├── UserRepositoryImpl.java
  43. │   │   │   ├── UserRepository.java
  44. │   │   │   ├── UserRoleRepositoryCustom.java
  45. │   │   │   ├── UserRoleRepositoryImpl.java
  46. │   │   │   └── UserRoleRepository.java
  47. │   │   └── service
  48. │   │   ├── UserRoleServiceImpl.java
  49. │   │   ├── UserRoleService.java
  50. │   │   ├── UserServiceImpl.java
  51. │   │   └── UserService.java
  52. │   └── resources
  53. │   ├── application.properties
  54. │   └── custom
  55. │   └── typedef.hbm.xml
  56. └── test
  57. ├── java
  58. │   └── com
  59. │   └── thalasoft
  60. │   └── userdata
  61. │   ├── assertion
  62. │   │   └── UserAssert.java
  63. │   ├── it
  64. │   │   ├── jpa
  65. │   │   │   ├── AbstractRepositoryTest.java
  66. │   │   │   ├── UserRepositoryTest.java
  67. │   │   │   └── UserRoleRepositoryTest.java
  68. │   │   └── service
  69. │   │   ├── AbstractServiceTest.java
  70. │   │   └── UserServiceTest.java
  71. │   └── ut
  72. │   ├── AbstractRepositoryTest.java
  73. │   └── UserRepositoryTest.java
  74. └── resources
  75. ├── h2
  76. │   └── data-source-test.properties
  77. ├── mysql
  78. │   ├── clean-up-before-each-test.sql
  79. │   └── data-source-test.properties
  80. └── oracle
  81. ├── data-source-preprod.properties
  82. └── data-source-test.properties
  83.  
  84. @EnvTest
  85. @DbH2
  86. @Configuration
  87. @PropertySource({ "classpath:h2/data-source-test.properties" })
  88. public class DatabaseH2TestProperties extends AbstractDatabaseProperties {
  89.  
  90. private static Logger logger = LoggerFactory.getLogger(DatabaseH2TestProperties.class);
  91.  
  92. public DatabaseH2TestProperties() {
  93. logger.debug("===========>> Loading the classpath h2/data-source-test.properties file");
  94. }
  95. }
  96.  
  97. spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
  98. spring.datasource.driver-class-name=net.sf.log4jdbc.DriverSpy
  99. spring.datasource.url=jdbc:log4jdbc:h2:file:./target/useraccounttest
  100. spring.datasource.username=sa
  101. spring.datasource.password=
  102. spring.jpa.show-sql=true
  103.  
  104. @ContextConfiguration(classes = { DatabaseConfiguration.class })
  105. @RunWith(SpringRunner.class)
  106. @Sql(executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, scripts = { "classpath:mysql/clean-up-before-each-test.sql" })
  107. public abstract class AbstractRepositoryTest {
  108. }
  109.  
  110. @EnableAutoConfiguration
  111. @ComponentScan(nameGenerator = PackageBeanNameGenerator.class, basePackages = { "com.thalasoft.userdata" })
  112. public class DatabaseConfiguration {
  113. }
  114.  
  115. 02:23:56.299 [main] DEBUG jdbc.audit - 100. Connection.getMetaData() returned dbMeta74: conn99: url=jdbc:h2:file:./target/useraccounttest user=SA com.zaxxer.hikari.pool.ProxyConnection.getMetaData(ProxyConnection.java:361)
  116. 02:23:56.299 [main] DEBUG org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator - Database ->
  117. name : H2
  118. version : 1.4.197 (2018-03-18)
  119. major : 1
  120. minor : 4
  121. 02:23:56.299 [main] DEBUG org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator - Driver ->
  122. name : H2 JDBC Driver
  123. version : 1.4.197 (2018-03-18)
  124. major : 1
  125. minor : 4
  126. 02:23:56.299 [main] DEBUG org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator - JDBC version : 4.0
  127. 02:23:56.299 [main] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
  128. 02:23:56.305 [main] DEBUG jdbc.audit - 100. Connection.clearWarnings() returned com.zaxxer.hikari.pool.ProxyConnection.close(ProxyConnection.java:250)
  129.  
  130. 02:23:56.338 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
  131. 02:23:56.338 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'com.thalasoft.userdata.config.JpaService'
  132. 02:23:56.338 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'com.thalasoft.userdata.config.properties.DatabaseH2TestProperties'
  133. 02:23:56.338 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'com.thalasoft.userdata.jpa.repository.GenericRepositoryImpl'
  134. 02:23:56.338 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'com.thalasoft.userdata.jpa.repository.GenericRepositoryImpl'
  135. 02:23:56.338 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
  136. 02:23:56.340 [main] WARN org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.thalasoft.userdata.jpa.repository.GenericRepositoryImpl' defined in file [/home/stephane/dev/java/projects/user-data/target/classes/com/thalasoft/userdata/jpa/repository/GenericRepositoryImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.Class<?>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  137.  
  138. @Repository
  139. @Transactional
  140. public class GenericRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
  141. implements GenericRepository<T, ID> {
  142.  
  143. private EntityManager entityManager;
  144.  
  145. private final Class<T> domainClass;
  146.  
  147. public GenericRepositoryImpl(Class<T> domainClass, EntityManager entityManager) {
  148. super(domainClass, entityManager);
  149. this.entityManager = entityManager;
  150. this.domainClass = domainClass;
  151. }
  152.  
  153. public EntityManager getEntityManager() {
  154. return entityManager;
  155. }
  156. }
  157.  
  158. @NoRepositoryBean
  159. public interface GenericRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {
  160.  
  161. public EntityManager getEntityManager();
  162. }
  163.  
  164. public interface UserRepository extends GenericRepository<User, Long>, UserRepositoryCustom {
  165. }
  166.  
  167. public interface UserRepositoryCustom {
  168.  
  169. public User deleteByUserId(Long id) throws EntityNotFoundException;
  170.  
  171. }
  172.  
  173. public class UserRepositoryImpl implements UserRepositoryCustom {
  174.  
  175. @Autowired
  176. private UserRepository userRepository;
  177.  
  178. }
Add Comment
Please, Sign In to add comment