<context:annotation-config />
<tx:annotation-driven />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="com.mysql.jdbc.Driver" p:url="${db.url}"
p:username="${db.username}" p:password="${db.password}" />
<!-- Hibernate 4 SessionFactory Bean definition -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.moneyhaul.dao.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!--<tx:annotation-driven transaction-manager="transactionManager" />-->
<!--
Configure Spring Data JPA and set the base package of the
repository interfaces
-->
<jpa:repositories base-package="com.moneyhaul.repositary"/>
<!-- Create default configuration for Hibernate -->
<bean id="hibernateJpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
<!-- Configure the entity manager factory bean -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/>
<!-- Set JPA properties -->
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="javax.persistence.schema-generation.database.action">none</prop>
<prop key="hibernate.ejb.use_class_enhancer">false</prop>
</props>
</property>
<!-- Set base package of your entities -->
<property name="packagesToScan" value="com.moneyhaul.dao.model"/>
<!-- Set share cache mode -->
<property name="sharedCacheMode" value="ENABLE_SELECTIVE"/>
<!-- Set validation mode -->
<property name="validationMode" value="NONE"/>
</bean>
<!-- Configure the transaction manager bean -->
<bean id="transactionManagerJpa"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- Enable annotation driven transaction management -->
<tx:annotation-driven transaction-manager="transactionManagerJpa"/>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Mybatis session factory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref="dataSource" p:configLocation="WEB-INF/mybatis/sqlmap-config.xml" />
<bean id="caarmoMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.CaarmoMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="paymentMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.PaymentMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="reportingMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.ReportingMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="reportingTrendsMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.ReportingTrendsMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="customerDBMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.CustomerDBMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="vehicleDBMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.VehicleDBMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="geomaticsMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.GeomaticsMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="serviceCenterMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.ServiceCenterMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="moneyhaulMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.moneyhaul.mapper.MoneyHaulMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="mhGeomaticsMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.moneyhaul.mapper.MHGeomaticsMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
<bean id="configurationMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
p:mapperInterface="com.caarmo.mapper.ConfigurationMapper"
p:sqlSessionFactory-ref="sqlSessionFactory" />
java
@Repository
public interface DriverRepositary extends CrudRepository<Driver,Long>{}
持久实体
@Transactional
public void addDriver(Driver driver) {
driver.setTabletPassword(setDriverPassword(driver.getPhone()));
driver.setUpdated(new Date());
driverRepositary.save(driver);
}
你能查一下下面的吗:
此外,如果可能的话,提供从服务器启动到此错误点的所有可用日志,以便进一步分析。
我的Spring主课:- 我的痛苦。属性 我在执行保存函数时的控制台输出:- 不要忘记我的集成测试类:=
问题内容: 我创建了一个这样的对象: 我想保存该对象。我怎样才能做到这一点? 问题答案: 你可以使用标准库中的模块。这是你的示例的基本应用: 你还可以定义自己的简单实用程序,如下所示,该实用程序打开文件并向其中写入单个对象: 更新资料 由于这是一个非常受欢迎的答案,因此,我想谈谈一些高级用法主题。 实际使用该cPickle模块几乎总是可取的,而不是因为该模块是用C编写的并且速度更快。它们之间有一些
我有一个问题,Spring数据没有保存实体。应用程序逻辑如下: 另一个应用程序正在监听负载相当重的Kafka主题(每秒数十条消息)并将消息插入数据库中具有“NEW”状态的表中。 @调度方法加载一个具有“NEW”状态的实体列表,这些实体被一个接一个地传输到FixedThreadPool(20个线程),它们的状态设置为“PROCESSING”和一个saveAll方法调用同一个表。 这两种日志方法都显示
我有一个实体CandidateTransaction和CandidateTransactionRepository扩展了CrudRepository 我正在使用CrudRepository的save方法来保存所述实体的对象。当实体没有行时,它将创建一个自动生成的键并将其插入ID列,而不需要Java端的干预。 而且,由于CrudRepository的save()方法检查实体是否是新的,如果是新的,它
我正在使用springboot jpa存储库保存方法 这是完整的错误:2020-06-09 15:49:02.371[nio-8080-exec-4]。M.M.A.ExceptionHandlerExceptionResolver:由处理程序执行导致的解析异常:org.springframework.dao.invalidDataAccessapiusageException:传递给persist
我在提交表单时遇到以下错误: org.hibernate.PersistentObjectException:传递给Persisted的分离实体:com.project.pmet.model.Account;嵌套异常为javax.persistence.persistenceException:org.hibernate.persistentObjectException:传递到persist的分