相关疑难解决方法(0)

Spring JPA 实体未保存到数据库

我在 Spring JPA 中遇到了一些问题。我成功配置了 Spring JPA 项目并且能够运行该项目而没有任何异常。

我打算将实体保存到数据库中。但是当我运行该项目时,它既不保存到数据库也不抛出任何异常。

可能是什么问题呢?我还添加了许多与休眠相关的 jar 文件,因为它在我运行时抛出异常。现在我没有得到任何例外。但实体不会保存到数据库中。我附上了我的 Spring 配置和 Java 类。

小枝配置

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:osgi="http://www.springframework.org/schema/osgi"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/osgi
            http://www.springframework.org/schema/osgi/spring-osgi.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx.xsd"> 



    <context:property-placeholder location="classpath:jdbc.properties"/>


        <!-- Connection Pool -->
     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass" value="${jdbc.driverClass}"/>
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
     </bean>

     <!-- JPA EntityManagerFactory --> 
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
            p:dataSource-ref="dataSource">
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="database" value="${jdbc.database}"/>
                    <property name="showSql" value="${jdbc.showSql}"/>                  
            </bean>     
        </property>
    </bean>

    <!-- Transaction manager for …
Run Code Online (Sandbox Code Playgroud)

java spring dao

5
推荐指数
1
解决办法
7233
查看次数

标签 统计

dao ×1

java ×1

spring ×1