META-INF.persistence-template.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redkale Show documentation
Show all versions of redkale Show documentation
redkale -- java framework
<?xml version="1.0" encoding="UTF-8"?> <!-- 其配置算是标准的JPA配置文件的缩略版 --> <persistence> <!-- 系统基本库 --> <persistence-unit name="demouser"> <!-- 为NONE表示不启动缓存,@Cacheable 失效; 非NONE值(通常用ALL)表示开启缓存。 --> <shared-cache-mode>NONE</shared-cache-mode> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/dbuser?characterEncoding=utf8"/> <!-- javax.persistence.jdbc.driver在JPA的值是JDBC驱动,Redkale有所不同,值应该是javax.sql.DataSource的子类。 为了兼容用户习惯,Redkale内置常见JDBC驱动到javax.sql.DataSource的映射关系: org.mariadb.jdbc.Driver —————— org.mariadb.jdbc.MySQLDataSource org.postgresql.Driver —————— org.postgresql.ds.PGConnectionPoolDataSource com.mysql.jdbc.Driver —————— com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource oracle.jdbc.driver.OracleDriver —————— oracle.jdbc.pool.OracleConnectionPoolDataSource com.microsoft.sqlserver.jdbc.SQLServerDriver —————— com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource 因此 com.mysql.jdbc.Driver 会被自动转换成 com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource 并且如果JDBC驱动是以上几个版本,javax.persistence.jdbc.driver属性都可以省略,Redkale会根据javax.persistence.jdbc.url的值来识别驱动 --> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> <property name="javax.persistence.jdbc.user" value="root"/> <property name="javax.persistence.jdbc.password" value="123456"/> <!-- 最大连接数,默认值:CPU数*16 --> <property name="javax.persistence.connections.limit" value="32"/> <!-- 包含的SQL模板,相当于反向LIKE,不同的JDBC驱动的SQL语句不一样,Redkale内置了MySQL的语句 --> <property name="javax.persistence.contain.sqltemplate" value="LOCATE(${keystr}, ${column}) > 0"/> <property name="javax.persistence.notcontain.sqltemplate" value="LOCATE(${keystr}, ${column}) = 0"/> <!-- 复制表结构的SQL模板,Redkale内置了MySQL的语句 --> <property name="javax.persistence.tablenotexist.sqlstates" value="42000;42S02"/> <property name="javax.persistence.tablecopy.sqltemplate" value="CREATE TABLE ${newtable} LIKE ${oldtable}"/> </properties> </persistence-unit> <!-- IM消息库 --> <persistence-unit name="demoim"> <shared-cache-mode>NONE</shared-cache-mode> <properties> <!-- jdbc:mysql://127.0.0.1:3306/dbim?autoReconnect=true&autoReconnectForPools=true&characterEncoding=utf8 --> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/dbim?characterEncoding=utf8"/> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> <property name="javax.persistence.jdbc.user" value="root"/> <property name="javax.persistence.jdbc.password" value="123456"/> </properties> </persistence-unit> </persistence>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy