Search in sources :

Example 1 with TestEntity

use of org.javaee7.jpa.datasourcedefinition_annotation_pu.entity.TestEntity in project javaee7-samples by javaee-samples.

the class TestService method saveEntities.

public void saveEntities() {
    TestEntity testEntity1 = new TestEntity();
    testEntity1.setValue("1");
    TestEntity testEntity2 = new TestEntity();
    testEntity2.setValue("2");
    entityManager.persist(testEntity1);
    entityManager.persist(testEntity2);
}
Also used : TestEntity(org.javaee7.jpa.aggregate_function_in_select.entity.TestEntity) AggregatedTestEntity(org.javaee7.jpa.aggregate_function_in_select.entity.AggregatedTestEntity)

Example 2 with TestEntity

use of org.javaee7.jpa.datasourcedefinition_annotation_pu.entity.TestEntity in project javaee7-samples by javaee-samples.

the class TestService method saveNewEntity.

public void saveNewEntity() {
    TestEntity testEntity = new TestEntity();
    testEntity.setValue("mytest");
    entityManager.persist(testEntity);
}
Also used : TestEntity(org.javaee7.jpa.datasourcedefinition_annotation_pu.entity.TestEntity)

Example 3 with TestEntity

use of org.javaee7.jpa.datasourcedefinition_annotation_pu.entity.TestEntity in project javaee7-samples by javaee-samples.

the class TestService method saveNewEntity.

public void saveNewEntity() {
    TestEntity testEntity = new TestEntity();
    testEntity.setValue("mytest");
    entityManager.persist(testEntity);
}
Also used : TestEntity(org.javaee7.jpa.datasourcedefinition_applicationxml_pu.entity.TestEntity)

Example 4 with TestEntity

use of org.javaee7.jpa.datasourcedefinition_annotation_pu.entity.TestEntity in project javaee7-samples by javaee-samples.

the class TestService method saveNewEntity.

public void saveNewEntity() {
    TestEntity testEntity = new TestEntity();
    testEntity.setValue("mytest");
    entityManager.persist(testEntity);
}
Also used : TestEntity(org.javaee7.jpa.datasourcedefinition_webxml_pu.entity.TestEntity)

Example 5 with TestEntity

use of org.javaee7.jpa.datasourcedefinition_annotation_pu.entity.TestEntity in project javaee7-samples by javaee-samples.

the class QueryRepository method buildGetByValue.

/**
     * Builds a criteria query equal to the JPQL
     * 
     * <code>SELECT _testEntity FROM TestEntity _testEntity WHERE _testEntity.value :value</code>
     * 
     *
     */
private TypedQuery<TestEntity> buildGetByValue() {
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<TestEntity> criteriaQuery = criteriaBuilder.createQuery(TestEntity.class);
    Root<TestEntity> root = criteriaQuery.from(TestEntity.class);
    ParameterExpression<String> valueParameter = criteriaBuilder.parameter(String.class, TestEntity_.value.getName());
    criteriaQuery.select(root).where(criteriaBuilder.equal(root.get(TestEntity_.value), valueParameter));
    return entityManager.createQuery(criteriaQuery);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) TestEntity(org.javaee7.jpa.dynamicnamedquery.entity.TestEntity)

Aggregations

TestEntity (org.javaee7.jpa.dynamicnamedquery.entity.TestEntity)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 AggregatedTestEntity (org.javaee7.jpa.aggregate_function_in_select.entity.AggregatedTestEntity)1 TestEntity (org.javaee7.jpa.aggregate_function_in_select.entity.TestEntity)1 TestEntity (org.javaee7.jpa.datasourcedefinition_annotation_pu.entity.TestEntity)1 TestEntity (org.javaee7.jpa.datasourcedefinition_applicationxml_pu.entity.TestEntity)1 TestEntity (org.javaee7.jpa.datasourcedefinition_webxml_pu.entity.TestEntity)1 Test (org.junit.Test)1