Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name="project")
- public class Project implements Serializable{
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
- private int id;
- @Column(name="teamId")
- private int teamId;
- //private String Rentabiliteit;
- @Column
- //@Index(name="IProject_status",columnNames="Status")
- private String status;
- @Column
- //@Index(name="IProject_naam",columnNames="Naam")
- private String naam;
- //public Prototype m_Prototype;
- //public Team m_Team;
- }
- CREATE TABLE IF NOT EXISTS `project` (
- `id` int(11) NOT NULL,
- `teamId` int(11) DEFAULT NULL,
- `status` varchar(255) DEFAULT NULL,
- `naam` varchar(255) DEFAULT NULL
- ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
- Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
- Unknown column 'project0_.team_id' in 'field list'
- spring:
- mvc:
- view:
- prefix: /WEB-INF/jsp/
- suffix: .jsp
- datasource:
- url: jdbc:mysql://localhost:3306/oxyplast
- username: oxyplastuser
- password: oxyplastuserpw
- jpa:
- properties:
- hibernate:
- current_session_context_class: org.springframework.orm.hibernate4.SpringSessionContext
- namingStrategy: org.hibernate.cfg.DefaultNamingStrategy
- spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.DefaultComponentSafeNamingStrategy
- spring-boot-starter-data-jpa: ➡ 1.5.2.RELEASE
- hibernate-core:5.0.12.Final
- PhysicalNamingStrategyStandardImpl
- public class PhysicalNamingStrategyImpl extends PhysicalNamingStrategyStandardImpl implements Serializable {
- public static final PhysicalNamingStrategyImpl INSTANCE = new PhysicalNamingStrategyImpl();
- @Override
- public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
- String nameModified;
- // Do whatever you want with the name modification
- return new Identifier(nameModified, name.isQuoted());
- }
- }
- @Override
- public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) {
- String nameModified;
- // Do whatever you want with the name modification
- return new Identifier(nameModified, name.isQuoted());
- }
- properties.put("hibernate.physical_naming_strategy", "my.Package.PhysicalNamingStrategyImpl");
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
- import org.springframework.boot.context.properties.ConfigurationProperties;
- import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.context.annotation.Primary;
- import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
- import org.springframework.orm.jpa.JpaTransactionManager;
- import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
- import org.springframework.transaction.PlatformTransactionManager;
- import org.springframework.transaction.annotation.EnableTransactionManagement;
- import javax.persistence.EntityManagerFactory;
- import javax.sql.DataSource;
- import java.util.HashMap;
- import java.util.Map;
- @Configuration
- @EnableTransactionManagement
- @EnableJpaRepositories(
- entityManagerFactoryRef = "entityManagerFactory",
- basePackages = { "com.xxxxxx.repository" }
- )
- public class SharedDataSourceConfig {
- @Value("${startup.ddl-auto}")
- String hbm2ddl;
- @Primary
- @Bean(name = "dataSource")
- @ConfigurationProperties("spring.datasource.shared")
- public DataSource customerDataSource() {
- return DataSourceBuilder.create().build();
- }
- @Primary
- @Bean(name = "entityManagerFactory")
- public LocalContainerEntityManagerFactoryBean entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("dataSource") DataSource dataSource) {
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("hibernate.hbm2ddl.auto", hbm2ddl);
- properties.put("hibernate.physical_naming_strategy", "my.package.PhysicalNamingStrategyImpl");
- return builder
- .dataSource(dataSource)
- .packages(PackageScannerHelper.getPackagesToScan())
- .persistenceUnit("shared")
- .properties(properties)
- .build();
- }
- @Primary
- @Bean(name = "transactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("entityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
- }
- @Column(name=""teamId"")
- private int teamId;
Add Comment
Please, Sign In to add comment