我正在尝试将我的Oracle数据库连接到我的项目。我想用hibernate做。我是新手。但是我得到了这个错误invalid arguments in call
。我一整天都在搜索谷歌,但我找不到可以解决我问题的答案。我也有一些问题
1)我想通过在spring boot中创建模型类来自动在oracle中创建表。为此我添加了persistence.xml
和application.properties
。我真的需要这个文件来制作我的表在春天自动使用模型类?还有我必须提到我的项目是web应用程序不是Hibernate
2)使用Hibernate创建数据库有什么好处?
我的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>
我的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
我的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>
非常感谢。