Groovy ActiveRecord

ActiveRecord support for Spring boot entity classes.

Лицензия

Лицензия

Категории

Категории

Groovy Языки программирования Ant Компиляция и сборка
Группа

Группа

it.nicolasanti
Идентификатор

Идентификатор

groovy-activerecord
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Groovy ActiveRecord
ActiveRecord support for Spring boot entity classes.
Ссылка на сайт

Ссылка на сайт

https://github.com/nicolinux72/groovy-activerecord
Система контроля версий

Система контроля версий

https://github.com/nicolinux72/groovy-activerecord.git

Скачать groovy-activerecord

Как подключить последнюю версию

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

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-data-jpa jar 1.3.0.RELEASE
org.codehaus.groovy : groovy-all jar 2.4.3
org.codehaus.groovy : groovy-templates jar 2.4.3

test (2)

Идентификатор библиотеки Тип Версия
hsqldb : hsqldb jar 1.8.0.10
org.springframework.boot : spring-boot-starter-test jar 1.3.0.RELEASE

Модули Проекта

Данный проект не имеет модулей.

Groovy ActiveRecord

This library adds ActiveRecord support to your groovy jpa entity inside a Spring Boot application. That's all.

Setup your project

Add grovy active-record library to your Spring Boot project dependencies. For example add these lines to your pom.xml file:

<dependency>
    <groupId>it.nicolasanti</groupId>
    <artifactId>groovy-activerecord</artifactId>
    <version>1.0.0</version>
</dependency>

Or this line to your build.gradle file:

compile 'it.nicolasanti:groovy-activerecord:1.0.0'

Please consider that this library work with early versio of Spring boot also, so you may consider to replace dependency to Spring Boot 1.3.0.RELEASE with the version your are actually use.

The last step is remember to scan for component the groovy-activerecord'jar also, something like this:

@ComponentScan("it.nicolasanti.autoconfigure")

Setup your entity class

Simpliy add the trait ActiveRecordRepository to your entity jpa entity class in this way:

@Entity  
class YourEntity implements ActiveRecordRepository {
  ...
}

Then Spring Boot, starting up your application, will add to your entity class standard Active Record methods like:

/** Perform a SELECT COUNT for this entity on database */
static countEntities() 
	
/** Return all entities store on database: pay attention on high volume tables. */
static findAllEntities() 
	
/** Retreive from database the entity with the passed primary key */
static  findEntity(id) 
	
/** Found all entities then paginate the results */
static findEntries( int firstResult, int maxResults) 
		
/** Persiste this instance */
def persist() 
	
/** Remove from db this instance */
def remove()  

/** Force EntityManager to flush pending changes */
void flush()  

/** Clear EntityManager */
void clear()  

/** Merge this instance with the one inside EntityManager  */
def merge()   

You could found all these methods inside the class [ActiveRecordRepository] (https://github.com/nicolinux72/groovy-activerecord/blob/master/src/main/groovy/it/nicolasanti/autoconfigure/ActiveRecordRepository.groovy)

Working example

If you are interested in see a workging example you could take a look to test classes: you'll find an entity class named Studente (with means student, in italian) with and id, a name and a surname as only properties. The injected ActiveRecord methods are tested in the class ActiveRecordTest.

Версии библиотеки

Версия
1.0.0