import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "AAA")
public class LogDetail implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "SEQ_NO")
@SequenceGenerator(name = "generatorName", sequenceName = "MySeqName")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generatorName")
private Long seqNo;
@Lob()
@Column(name = "CONTENT", columnDefinition = "CLOB")
private String content;
@Column(name = "STATUS")
private String status;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "SEND_DATE")
private Date sendDate;
}
}
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Embeddable
public class CustomerPK implements Serializable{
private String code;
private String currency;
}
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface LogRepository extends CrudRepository<Log, Long> {
@Modifying
@Query("update Log set status = 0 where id = :id ")
void batchUpdate(@Param("id") Long id);
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
</bean>
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="false" />
<property name="database" value="ORACLE" />
</bean>
</property>
<property name="persistenceUnitName" value="demo.unit" />
<property name="persistenceUnitPostProcessors">
<list>
<ref bean="sstsPersistenceUnitPostProcessor" />
</list>
</property>
</bean>
<bean id="em" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
<property name="entityManagerFactory" ref="emf" />
</bean>
<bean id="demoPersistenceUnitPostProcessor" class="com.xx.DemoPersistenceUnitPostProcessor">
<property name="mappingFileNames">
<list>
<value>META-INF/entity/${instance.name}/Person.orm.xml</value>
</list>
</property>
</bean>
<!-- Translate Hibernate or JPA exceptions to Spring's generic DataAccessException. -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- bean post-processor for JPA annotations -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- jdbcTemplate -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="jdbcDao" class="com.xx.spring.JdbcDao">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>
</bean>
</beans>
分享到:
相关推荐
Spring Data JPA Demo
springdata-jpa demo http://knight-black-bob.iteye.com/blog/2274879
spring data Neo4j 整合demo,基本整合案例,详细细节参考https://docs.spring.io/spring-data/neo4j/docs/5.1.3.RELEASE/reference/html
理想国SpringDataElasticsearch入门教程源码
maven工程下的springDataJpa测试demo,mysql数据库
spring data jpa 简单demo
简单的springMVC入门程序配置Spring data jpa亲测可完美运行
SpringDataRedis客户端 SpringData是Spring中数据操作的模块,包含对各种数据库的集成,其中对Redis的集成模块就叫做SpringDataRedis,官网地址:https://spring.io/projects/spring-data-redis - 提供了对不同...
Spring-Data-Redis使用的实例Demo
spring-data-redis-demo.rar。 Spring-data-redis是spring大家族的一部分,提供了在srping应用中通过简单的配置访问redis服务,对reids底层开发包(Jedis, JRedis, and RJC)进行了高度封装,RedisTemplate提供了redis...
spring-data-redis的配置和使用demo; 大家下载完成后,只需要修改一下redis.properties配置文件中的相关参数即可
springdata实例demo+mysql数据库代码通过阿里规约检测,代码没有警告或异常,含sql文件,适合初学者学习使用。
)、Spring Cloud Bus、Spring Cloud for Cloud Foundry、Spring Cloud Cluster、Spring Cloud Consul、Spring Cloud Security、Spring Cloud Sleuth、Spring Cloud Data Flow、Spring Cloud Stream、Spring Cloud ...
基础框架,可满足开发需要
使用Spring MVC3.0+Spring+Spring data JPA 参照springside的一个小Demo
springboot+spring data jpa+thymeleaf学习简单完整的web项目整合demo源码
SpringMVC+Spring Data JPA+Shiro+EasyUI 整合的简单demo
spring-data-redis集成jedis简单demo。 包括和spring mvc 的简单集成
Spring boot,基于gradle构建,数据库:postgres,数据成:Spring data jpa
SpringMVC + Spring + SpringData\JPA 整合Demo,下载后直接可以在本地跑起来,涉及的技术比较全面