Reputation: 1664
I have two different data sources in spring boot project. One of the datasource's schema name is fraud and the other one is test. When I try to insert an object into the table, I am getting an error such as
java.lang.IllegalArgumentException: org.hibernate.dialect.identity.IdentityColumnSupportImpl does not support identity key generation
I tried this to solve my problem
org.hibernate.dialect.OracleDialect does not support identity key generation
But this one gives an error such as
ORA-02289: sequence does not exist
Thanks
if (channel.isAnyConvertionFailed()) {
FraudChannelException fce = new FraudChannelException(/*Params*/);
fraudChannelExceptionRepository.save(fce);
}
//Check if any mandatory fields are empty
if (/*condition*/){
FraudChannelException fce = new FraudChannelException(/*Params*/);
fraudChannelExceptionRepository.save(fce);
return ExceptionConfiguration.handleMissingFieldError(message);
}
@Repository
public interface FraudChannelExceptionRepository extends CrudRepository<FraudChannelException, Integer> {
}
@Entity
@Table(name="fraud_channel_exceptions", schema = "fraud")
public class FraudChannelException implements Serializable {
@Id
@Column(name = "ID")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
//more fields
public FraudChannelException(/*PARAMS*/) {
//init something
}
public FraudChannelException(/*PARAMS*/) {
//init something
}
public FraudChannelException(/*PARAMS*/) {
//init something
}
public FraudChannelException() {
}
//Getter Setter
}
@Configuration
@PropertySource({ "classpath:application.properties" })
@EnableJpaRepositories(basePackages = "com.ykb.frd.fraudcore.schema.fraud.repo",entityManagerFactoryRef = "entityManager",transactionManagerRef = "transactionManager")
public class FraudConfig{
@Autowired
private Environment env;
@Bean
@Primary
public LocalContainerEntityManagerFactoryBean entityManager() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan("com.ykb.frd.fraudcore.schema.fraud.domain");
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
HashMap<String, Object> properties = new HashMap<>();
properties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
properties.put("hibernate.dialect", env.getProperty("hibernate.dialect"));
em.setJpaPropertyMap(properties);
return em;
}
@Primary
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource= new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("fraud.datasource.driverClassName"));
dataSource.setUrl(env.getProperty("fraud.datasource.url"));
dataSource.setUsername(env.getProperty("fraud.datasource.username"));
dataSource.setPassword(env.getProperty("fraud.datasource.password"));
return dataSource;
}
@Primary
@Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager transactionManager= new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManager().getObject());
return transactionManager;
}
}
# EBNKTST - NDVLIVE
ndvlive.datasource.url=jdbc:oracle:thin:@//URL
ndvlive.datasource.username=//USERNAME
ndvlive.datasource.password=//PASSWORD
ndvlive.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
# EBNKDEV - FRAUD
fraud.datasource.url=jdbc:oracle:thin:@//URL
fraud.datasource.username=//USERNAME
fraud.datasource.password=//PASSWORD
fraud.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
# logging
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=debug
Upvotes: 1
Views: 6136
Reputation: 8086
Hibernate expects from underlying database to provide an auto increment feature for a given property, in your case it's id
. IOW, Oracle(your case) should support auto increment feature for a field. Oracle started to provide auto increment feature with 12c version and, as your version is less, you get that exception .
Upvotes: 1