0

I am trying to connect my Oracle database to my project.And I want to do with hibernate.I am new beginner.But I get this error says invalid arguments in call. I have been searching google whole day, but I do not get answer which can solve my problem.Also I have some questions

1) I want to do automatically make my table in oracle by making model class in spring boot.For this I add persistence.xml and application.properties.Do I really need both this file to make my table automatically with model class in spring?Also I have to mention that my project is web application not Hibernate

2)What is benefit of making database with Hibernate?

My pom.xml

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.clojure/java.jdbc -->
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.12.Final</version>
    </dependency>


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


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


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


    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.2.3.Final</version>
    </dependency>


    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.4.0</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

My application.properties

spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/XE
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.data-username=GULSHAN
spring.datasource.data-password=
spring.jpa.hibernate.ddl-auto=create
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect

And my persistence.xml

    <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
             http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="org.hibernate.tutorial.jpa">

        <properties>
            <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
            <property name="hibernate.connection.url" value="jdbc:oracle:thin:@//localhost:1521/XE"/>
            <property name="hibernate.connection.autocommit" value="false"/>
            <property name="hibernate.connection.username" value="gulshan"/>
            <property name="hibernate.connection.password" value="pass"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
            <property name="hibernate.connection.CharSet" value="utf8"/>
            <property name="hibernate.connection.characterEncoding" value="utf8"/>
            <property name="hibernate.connection.useUnicode" value="true"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
        </properties>
    </persistence-unit>
</persistence>

Thanks anyway.

Gulshan
  • 35
  • 1
  • 7
  • "Also I have to mention that my project is web application not Hibernate" didn't get this – rupesh_padhye Dec 02 '17 at 17:14
  • First of all spring boot starter jpa will be sufficient enough to create tables. No need to add Hibernate in your pom. Also, properties file is enough for your needs. Persistence.xml hence not required. Also have a look at this . : https://stackoverflow.com/questions/26881739/unable-to-get-spring-boot-to-automatically-create-database-schema – Number945 Dec 02 '17 at 17:19
  • By making project in Hibernate make `persistence.xml` automatically,but I make `persistence.xml` myself.Also I may understand wrong so I ask questions – Gulshan Dec 02 '17 at 17:25
  • You dont need hibernate when you are using spring boot jpa. Also post the folder structure and files in project. That will be more helpful or better a github link. – Number945 Dec 02 '17 at 17:35
  • @ Breaking Benjamin Thanks you – Gulshan Dec 02 '17 at 17:40

0 Answers0