Skip to Content
0
Feb 28, 2019 at 03:16 AM

Cannot create tables using Spring boot in HANA HDI container without CDS artifact

1272 Views

Hi,

I have a basic spring boot application comprising of a Entity (called Topic) and a service that allows CRUD operations on it. I had deployed the application on SAP Cloud Platform - Neo and binded it with the Hana Classic Schema. Hibernate was able to execute DML statements i.e was successful in generating the table in schema.

Now, I tried deploying the same application to Cloud Foundry using HANA hdi containers. The application got deployed but the tables were not created . I checked the logs and it shows me that create operation could not be successful because of insufficient privileges. I do not have any CDS artifact in my project. Is that the reason ? Can we not create database objects via JPA/Hibernate without depending on hdb artifacts for HANA hdi containers ?

Attaching the code and logs below -

1. The logs show the following error -

1. application.properties - springdb is the name of the hana instance and springdatabase is the spring boot application

spring.jpa.hibernate.ddl-auto=update
vcap.services.name=springdb
spring.datasource.driver-class-name=${vcap.services.${vcap.services.name}.credentials.driver}
spring.datasource.url=${vcap.services.${vcap.services.name}.credentials.url}
spring.datasource.username=${vcap.services.${vcap.services.name}.credentials.user}
spring.datasource.password=${vcap.services.${vcap.services.name}.credentials.password}

HANA Service -

2. The main class -

@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration.class})
@ComponentScan("io.javabrains.*")
@EnableJpaRepositories(basePackages = {"io.javabrains.*"})
@EntityScan("io.javabrains.*")
public class SpringDatabaseApplication {
public static void main(String[] args) {
SpringApplication.run(SpringDatabaseApplication.class, args);
}
}

3. The pom. xml -

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.javabrains</groupId>
<artifactId>SpringDatabase</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SpringDatabase</name>
<description>Demo project for Spring Boot JPA</description>
<properties>

<java.version>1.8</java.version>
<maven.test.skip>true</maven.test.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>

<exclusions>
                <exclusion>
                    <artifactId>logback-classic</artifactId>
                    <groupId>ch.qos.logback</groupId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

 <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.tomcat.embed</groupId>
                    <artifactId>tomcat-embed-el</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>logback-classic</artifactId>
                    <groupId>ch.qos.logback</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-logging</artifactId>
    <scope>provided</scope>
</dependency>
 <!--  <dependency>
<groupId>com.sap.cloud</groupId>
<artifactId>neo-java-web-api</artifactId>
<version>3.34.3</version>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

<profiles>
<profile>
    <id>neo</id>
    <properties>
        <activatedProperties>neo</activatedProperties>
    </properties>
    <activation>
        <activeByDefault>false</activeByDefault>
    </activation>
</profile>
<profile>
    <id>cf</id>
    <properties>
        <activatedProperties>cf</activatedProperties>
    </properties>
    <!--  <dependencies>
    <dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies> -->
<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-cloudfoundry-connector</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-spring-service-connector</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.sap.cloud.db.jdbc/ngdbc -->
<dependency>
    <groupId>com.sap.db.jdbc</groupId>
<artifactId>ngdbc</artifactId>
<version>1.102.0</version>
</dependency>

    </dependencies>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
</profile>
</profiles>
</project>

As you can see from the logs, it says that create operation failed. Why is it so ?

Regards

Attachments

1.png (6.8 kB)
2.png (109.5 kB)
3.png (107.1 kB)