orm

Orm configuration using java config

License

License

Categories

Categories

ORM Data
GroupId

GroupId

com.github.jetqin
ArtifactId

ArtifactId

orm
Last Version

Last Version

1.1.7
Release Date

Release Date

Type

Type

jar
Description

Description

orm
Orm configuration using java config
Project URL

Project URL

https://github.com/JetQin/orm_configuration
Source Code Management

Source Code Management

https://github.com/JetQin/orm_configuration.git

Download orm

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.jetqin/orm/ -->
<dependency>
    <groupId>com.github.jetqin</groupId>
    <artifactId>orm</artifactId>
    <version>1.1.7</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.jetqin/orm/
implementation 'com.github.jetqin:orm:1.1.7'
// https://jarcasting.com/artifacts/com.github.jetqin/orm/
implementation ("com.github.jetqin:orm:1.1.7")
'com.github.jetqin:orm:jar:1.1.7'
<dependency org="com.github.jetqin" name="orm" rev="1.1.7">
  <artifact name="orm" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.jetqin', module='orm', version='1.1.7')
)
libraryDependencies += "com.github.jetqin" % "orm" % "1.1.7"
[com.github.jetqin/orm "1.1.7"]

Dependencies

compile (8)

Group / Artifact Type Version
org.springframework : spring-orm jar 4.2.1.RELEASE
org.springframework : spring-context-support jar 4.2.1.RELEASE
org.apache.commons : commons-dbcp2 jar 2.0
net.sf.ehcache : ehcache-core jar 2.6.11
org.hibernate : hibernate-core jar 4.3.11.Final
org.hibernate : hibernate-entitymanager jar 4.3.11.Final
org.hibernate : hibernate-ehcache jar 4.3.11.Final
org.projectlombok : lombok jar 1.16.6

test (1)

Group / Artifact Type Version
junit : junit jar 3.8.1

Project Modules

There are no modules declared in this project.

@EnableOrmConfiguration

implement hibernate config use java config annotation

Parameters:

#####display sql or not

showSql: boolean default value false;

#####which package to scan

packageToScan:String[] default value new String[]{};

#####which way to implementation,Hibernate or JPA

OrmType: enum default value OrmType.Hibernate; OrmType.Hibernate (Hibernate implementation) OrmType.Jpa (JPA implementation)

How to use

a simple example

  • Create a property file to setup database parameter and hibernate parameter

     connection.driver_class = oracle.jdbc.OracleDriver
     connection.url = jdbc:oracle:thin:@localhost:1521:XE
     connection.username = rdm
     connection.password = 123456
     hibernate.dialect = org.hibernate.dialect.Oracle9iDialect
     
     hibernate.dbcp.initialSize = 10
     hibernate.dbcp.maxActive = 100
     hibernate.dbcp.maxIdle = 10
     hibernate.dbcp.minIdle = 10
    
  • Add @EnableOrmConfiguration at the main configuration file

     @EnableOrmConfiguration(packageToScan="com.example.domain",showSql=false,enableCache=true)
    
    
  • Add package "com.github.jetqin.configuration*" to componentScan parameter

     @ComponentScan(basePackages={"com.example.*","com.github.jetqin.configuration*"})
     
    
Below is an example configuration
@Configuration
@ComponentScan(basePackages={"com.example.*","com.github.jetqin.configuration*"})
@EnableOrmConfiguration(showSql=false,packageToScan="com.example.domain",enableCache=true)
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Configuration Properties

connection.driver_class = oracle.jdbc.OracleDriver
connection.url = jdbc:oracle:thin:@localhost:1521:ORCL
connection.username = username
connection.password = password
hibernate.dialect = org.hibernate.dialect.Oracle9iDialect

hibernate.dbcp.initialSize = 10
hibernate.dbcp.maxActive = 100
hibernate.dbcp.maxIdle = 10
hibernate.dbcp.minIdle = 10

Maven dependency


<dependency>
		<groupId>com.github.jetqin</groupId>
		<artifactId>orm</artifactId>
		<version>1.1.5</version>
</dependency>

Reference Spring enable annotation

Versions

Version
1.1.7
1.1.5
1.1.2
1.0.20
1.0.19