Entity Assist

A Domain Driven SQL Builder Generator for JPMS/JDK8

Лицензия

Лицензия

Категории

Категории

GUI Взаимодействие с пользователем Guice Библиотеки уровня приложения Dependency Injection
Группа

Группа

com.jwebmp.guicedee.persistence
Идентификатор

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

entity-assist
Последняя версия

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

0.68.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Entity Assist
A Domain Driven SQL Builder Generator for JPMS/JDK8
Ссылка на сайт

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

https://github.com/GedMarc/EntityAssist
Организация-разработчик

Организация-разработчик

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

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

https://github.com/GedMarc/EntityAssist.git

Скачать entity-assist

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

<!-- https://jarcasting.com/artifacts/com.jwebmp.guicedee.persistence/entity-assist/ -->
<dependency>
    <groupId>com.jwebmp.guicedee.persistence</groupId>
    <artifactId>entity-assist</artifactId>
    <version>0.68.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.jwebmp.guicedee.persistence/entity-assist/
implementation 'com.jwebmp.guicedee.persistence:entity-assist:0.68.0.1'
// https://jarcasting.com/artifacts/com.jwebmp.guicedee.persistence/entity-assist/
implementation ("com.jwebmp.guicedee.persistence:entity-assist:0.68.0.1")
'com.jwebmp.guicedee.persistence:entity-assist:jar:0.68.0.1'
<dependency org="com.jwebmp.guicedee.persistence" name="entity-assist" rev="0.68.0.1">
  <artifact name="entity-assist" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jwebmp.guicedee.persistence', module='entity-assist', version='0.68.0.1')
)
libraryDependencies += "com.jwebmp.guicedee.persistence" % "entity-assist" % "0.68.0.1"
[com.jwebmp.guicedee.persistence/entity-assist "0.68.0.1"]

Зависимости

compile (9)

Идентификатор библиотеки Тип Версия
com.jwebmp.guicedee.persistence : guiced-persistence jar
com.jwebmp.jpms.commons : commons-text jar
org.hibernate : hibernate-core jar
com.jwebmp.jpms.commons : commons-lang3 jar
com.google.guava : guava jar
org.junit.jupiter : junit-jupiter-api jar
org.assertj : assertj-core jar
org.mockito : mockito-core jar
org.hamcrest : hamcrest-all jar

provided (2)

Идентификатор библиотеки Тип Версия
org.projectlombok : lombok jar
org.mapstruct : mapstruct-processor jar

test (3)

Идентификатор библиотеки Тип Версия
com.jwebmp.guicedee.persistence : guiced-persistence-btm jar
com.jwebmp.guicedee.persistence : guiced-persistence-jpa jar
com.h2database : h2 jar

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

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

Entity Assist

The ultimate Criteria SQL Generator utlizing CRP, AOP and designed in a complete DDD environment.

Utilizing the Metamodel, and forcing the builder to be strictly tied to the entity, you can wrap your common statements in easy-to-use methods.

Artifactory : http://www.jwebswing.com/artifactory/

Direct Link : https://jwebmp/artifactory/list/libs-snapshot-local/za/co/mmagon/entity-assist/

Getting Started

    <dependency>
        <groupId>com.entityassist</groupId>
        <artifactId>entity-assist</artifactId>
        <version>RELEASE</version>
        <type>jar</type>
     </dependency>

*Deployment to maven central scheduled for April

Creating your queries

Standard operation allows for simplistic query writing.

The return methods are get(), and getAll() where get() will return an optional of a single result, and getAll() will return all results)

List<EntityClass> list = new EntityClass().builder()
				                         .inDateRange()
				                         .join(EntityClassTwo_.entityClass)
				                         .getAll();
				                         
builder().where(Visitors_.localStorageKey, Operand.Equals,"Value");
		builder().where(Visitors_.localStorageKey, Operand.Like,"Value");
		builder().where(Visitors_.localStorageKey, Operand.NotLike,"Value");

By default all entities inherit the builder() method that configures and constructs your entities

Building queries

The builder method grants access to the entire builder API,

builder()
				.selectAverage(Visitors_.id)
				.selectCount(Visitors_.id)
				.selectMax(Visitors_.id)
				.selectMin(Visitors_.id)
				.selectSum(Visitors_.id)
				.selectSumAsDouble(Visitors_.id)
				.selectSumAsLong(Visitors_.id)
				.selectCountDistinct(Visitors_.id)
				.groupBy(Visitors_.subscribersList)
				.orderBy(Visitors_.id, OrderByType.ASC)
				.construct(Visitors.class)
				.detach()
				.update(new Visitors())
				.noLock()
				.setRunDetached(true)
				.where(Visitors_.localStorageKey,Operand.NotInList,new HashSet<>())
				.where(Visitors_.localStorageKey,Operand.NotInList,new ArrayList<>())
				.where(Visitors_.localStorageKey,Operand.NotInList,new Visitors[0])

Making easy to re-use methods

The builder class can also be used to dynamic query generation to group commonly used expressions into an easy-to-read format

Optional<Subscribers> found = new Subscribers().builder.findByEmail("mailaddress@from.com").get();
Optional<Subscribers> authenticated = new Subscribers().builder.findByEmail("mailaddress@from.com").withPassword("encryptedPassword1").get();
Optional<Subscribers> accountConfirmed = new Subscribers().builder.withUnconfirmedKey().get();

public SubscribersBuilder findByEmail(String email)
{
    where(Subscribers_.emailAddress, Equals, email);
    return this;
}

public SubscribersBuilder findByConfirmationKey(String confirmationKey)
{
    where(Subscribers_.confirmationKey, Equals, confirmationKey);
    return this;
}

public SubscribersBuilder withUnconfirmedKey()
{
    where(Subscribers_.confirmed, Equals, false);
    return this;
}

public SubscribersBuilder findNewSubscribed()
{
    where(Subscribers_.unsubscribed, Equals, false);
    return this;
}

public SubscribersBuilder findNewsUnsubscribed()
{
    where(Subscribers_.unsubscribed, Equals, true);
    return this;
}

public SubscribersBuilder withPassword(String password)
{
    where(Subscribers_.password, Equals, password);
    return this;
}

Configuring An Entity

Entities are configured through type safety and CRP, and are strictly tied to a builder (QueryBuilderExecutor)

class Entity<J,Q,I> extends BaseEntity

J> is always the type of the type being referenced (CRP)

Q> is the query builder instance that must extend QueryBuilderExecutor

I> is the serializable that identifies they Entity Key. Embedded and Mapped keys are of course allowed

class EntityBuilder<J,E,I> extends QueryBuilderExecutor

J> is always the type being referred (EntityBuilder in the example)

E> is the entity type that maps properly to the strictly typed class

I> is the key type (Forced type safety between builder and entity

Example

https://github.com/GedMarc/EntityAssist/tree/master/src/test/java/za/co/mmagon/entityassist/entities

public class EntityClass extends BaseEntity<EntityClass, EntityClassBuilder, Long>

public class EntityClassBuilder extends QueryBuilderCore<EntityClassBuilder, EntityClass, Long>

It has everything

The API is incredibly easy to use, and while we write out the wiki, you are more than free to log issues, make requests and improve on the stability (Although we are already using this in production)

Order By, Group By, Having, Count, Select Columns, Construct, Detach, Insert, Update, Batch Criteria Update Delete and Insert all there ready for you.

Inherit Dependencies

  • Guice 4.1
  • GuiceContent - A complete injection management framework for Guice. This is included for cross-compatibility with any Standalone, EE or specific WELD implementation.
  • GuicedPersistence (optional) - A complete JTA1.1 BTM operated management library. Ensure that your unit/integrated test environment matches your production environment 100% with no nasty surprises based on environment or container.

Support

Support is offered free of charge, and the library is maintained (although we have pretty much ironed everything out)

  • Tested on Wildlyfly >= 10
  • Tested on Glassfish >= 4.1
  • Tested on WebSphere
  • Tested on Standalone
  • Tested on Tomcat
  • Tested on TomEE
  • Tested on JBoss
  • Tested on Payara
  • Tested on Payara MP >= 1.0
  • Tested on Wildfly Swarm MP
  • Jetty/Catalina

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

Версия
0.68.0.1
0.67.0.16
0.67.0.15
0.67.0.12
0.67.0.9
0.67.0.7
0.67.0.5
0.67.0.4
0.67.0.3
0.67.0.2
0.67.0.1