Guest User

Untitled

a guest
Nov 16th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. @Entity
  2. @Table(name="project")
  3. public class Project implements Serializable{
  4.  
  5. private static final long serialVersionUID = 1L;
  6.  
  7. @Id
  8. @GeneratedValue(strategy=GenerationType.AUTO)
  9. @Column(name="id")
  10. private int id;
  11.  
  12. @Column(name="teamId")
  13. private int teamId;
  14.  
  15. //private String Rentabiliteit;
  16.  
  17. @Column
  18. //@Index(name="IProject_status",columnNames="Status")
  19. private String status;
  20.  
  21. @Column
  22. //@Index(name="IProject_naam",columnNames="Naam")
  23. private String naam;
  24. //public Prototype m_Prototype;
  25. //public Team m_Team;
  26.  
  27. }
  28.  
  29. CREATE TABLE IF NOT EXISTS `project` (
  30. `id` int(11) NOT NULL,
  31. `teamId` int(11) DEFAULT NULL,
  32. `status` varchar(255) DEFAULT NULL,
  33. `naam` varchar(255) DEFAULT NULL
  34. ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
  35.  
  36. Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
  37. Unknown column 'project0_.team_id' in 'field list'
  38.  
  39. spring:
  40.  
  41. mvc:
  42. view:
  43. prefix: /WEB-INF/jsp/
  44. suffix: .jsp
  45.  
  46. datasource:
  47. url: jdbc:mysql://localhost:3306/oxyplast
  48. username: oxyplastuser
  49. password: oxyplastuserpw
  50.  
  51. jpa:
  52. properties:
  53. hibernate:
  54. current_session_context_class: org.springframework.orm.hibernate4.SpringSessionContext
  55. namingStrategy: org.hibernate.cfg.DefaultNamingStrategy
  56.  
  57. spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.DefaultComponentSafeNamingStrategy
  58.  
  59. spring-boot-starter-data-jpa: ➡ 1.5.2.RELEASE
  60. hibernate-core:5.0.12.Final
  61.  
  62. PhysicalNamingStrategyStandardImpl
  63.  
  64. public class PhysicalNamingStrategyImpl extends PhysicalNamingStrategyStandardImpl implements Serializable {
  65.  
  66. public static final PhysicalNamingStrategyImpl INSTANCE = new PhysicalNamingStrategyImpl();
  67.  
  68. @Override
  69. public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
  70. String nameModified;
  71. // Do whatever you want with the name modification
  72. return new Identifier(nameModified, name.isQuoted());
  73. }
  74.  
  75. }
  76.  
  77. @Override
  78. public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) {
  79. String nameModified;
  80. // Do whatever you want with the name modification
  81. return new Identifier(nameModified, name.isQuoted());
  82. }
  83.  
  84. properties.put("hibernate.physical_naming_strategy", "my.Package.PhysicalNamingStrategyImpl");
  85.  
  86. import org.springframework.beans.factory.annotation.Qualifier;
  87. import org.springframework.beans.factory.annotation.Value;
  88. import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
  89. import org.springframework.boot.context.properties.ConfigurationProperties;
  90. import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
  91. import org.springframework.context.annotation.Bean;
  92. import org.springframework.context.annotation.Configuration;
  93. import org.springframework.context.annotation.Primary;
  94. import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  95. import org.springframework.orm.jpa.JpaTransactionManager;
  96. import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
  97. import org.springframework.transaction.PlatformTransactionManager;
  98. import org.springframework.transaction.annotation.EnableTransactionManagement;
  99.  
  100. import javax.persistence.EntityManagerFactory;
  101. import javax.sql.DataSource;
  102. import java.util.HashMap;
  103. import java.util.Map;
  104.  
  105.  
  106. @Configuration
  107. @EnableTransactionManagement
  108. @EnableJpaRepositories(
  109. entityManagerFactoryRef = "entityManagerFactory",
  110. basePackages = { "com.xxxxxx.repository" }
  111. )
  112. public class SharedDataSourceConfig {
  113.  
  114. @Value("${startup.ddl-auto}")
  115. String hbm2ddl;
  116.  
  117. @Primary
  118. @Bean(name = "dataSource")
  119. @ConfigurationProperties("spring.datasource.shared")
  120. public DataSource customerDataSource() {
  121. return DataSourceBuilder.create().build();
  122. }
  123.  
  124. @Primary
  125. @Bean(name = "entityManagerFactory")
  126. public LocalContainerEntityManagerFactoryBean entityManagerFactory(
  127. EntityManagerFactoryBuilder builder,
  128. @Qualifier("dataSource") DataSource dataSource) {
  129. Map<String, Object> properties = new HashMap<String, Object>();
  130. properties.put("hibernate.hbm2ddl.auto", hbm2ddl);
  131. properties.put("hibernate.physical_naming_strategy", "my.package.PhysicalNamingStrategyImpl");
  132. return builder
  133. .dataSource(dataSource)
  134. .packages(PackageScannerHelper.getPackagesToScan())
  135. .persistenceUnit("shared")
  136. .properties(properties)
  137. .build();
  138. }
  139.  
  140. @Primary
  141. @Bean(name = "transactionManager")
  142. public PlatformTransactionManager transactionManager(
  143. @Qualifier("entityManagerFactory") EntityManagerFactory
  144. entityManagerFactory
  145. ) {
  146. return new JpaTransactionManager(entityManagerFactory);
  147. }
  148. }
  149.  
  150. @Column(name=""teamId"")
  151.  
  152. private int teamId;
Add Comment
Please, Sign In to add comment